@wordpress/block-editor 16.0.1-next.v.202607070741.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 +27 -1
- 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-canvas/index.cjs +6 -1
- package/build/components/block-canvas/index.cjs.map +2 -2
- package/build/components/block-controls/groups.cjs +3 -1
- package/build/components/block-controls/groups.cjs.map +2 -2
- package/build/components/block-edit/edit.cjs +10 -18
- package/build/components/block-edit/edit.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/block.cjs +9 -3
- package/build/components/block-list/block.cjs.map +3 -3
- package/build/components/block-list/index.cjs +1 -3
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +7 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +9 -4
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +11 -4
- 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/index.cjs +43 -24
- package/build/components/block-toolbar/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-tools/index.cjs +7 -2
- package/build/components/block-tools/index.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/block-visibility/modal.cjs +20 -6
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +16 -6
- package/build/components/block-visibility/use-block-visibility.cjs.map +3 -3
- package/build/components/block-visibility/utils.cjs +15 -2
- package/build/components/block-visibility/utils.cjs.map +3 -3
- package/build/components/block-visibility/viewport-menu-item.cjs +7 -1
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +5 -0
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +5 -1
- package/build/components/block-visibility/viewport-visibility-info.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/child-layout-control/index.cjs +0 -4
- package/build/components/child-layout-control/index.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-badges.cjs +39 -3
- package/build/components/global-styles/state-control-badges.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 -79
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/image-size-control/index.cjs +2 -4
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +33 -6
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +78 -16
- package/build/components/inserter/media-tab/media-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/keyboard-shortcuts/index.cjs +19 -11
- package/build/components/keyboard-shortcuts/index.cjs.map +2 -2
- package/build/components/line-height-control/index.cjs +1 -2
- 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/list-view/block.cjs +13 -4
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +0 -1
- package/build/components/media-placeholder/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/event-listeners/before-input-rules.cjs +3 -4
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +2 -3
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +3 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-events.cjs +3 -3
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +3 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs +2 -1
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +76 -17
- 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/typewriter/index.cjs +129 -136
- package/build/components/typewriter/index.cjs.map +3 -3
- package/build/components/url-input/index.cjs +303 -344
- package/build/components/url-input/index.cjs.map +3 -3
- package/build/components/use-block-commands/index.cjs +21 -17
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +1 -1
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +14 -1
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +42 -6
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +29 -3
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-clipboard-handler.cjs +4 -1
- package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
- package/build/components/writing-flow/use-drag-selection.cjs +3 -8
- package/build/components/writing-flow/use-drag-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 +75 -0
- package/build/components/writing-flow/use-editable-root.cjs.map +7 -0
- package/build/components/writing-flow/use-home-end.cjs +64 -0
- package/build/components/writing-flow/use-home-end.cjs.map +7 -0
- package/build/components/writing-flow/use-input.cjs +15 -5
- package/build/components/writing-flow/use-input.cjs.map +2 -2
- package/build/components/writing-flow/use-multi-selection.cjs +2 -2
- package/build/components/writing-flow/use-multi-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-select-all.cjs +14 -2
- package/build/components/writing-flow/use-select-all.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +132 -22
- package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
- package/build/components/writing-flow/utils.cjs +28 -2
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/hooks/background.cjs +14 -10
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-fields/rich-text/index.cjs +2 -3
- package/build/hooks/block-fields/rich-text/index.cjs.map +3 -3
- 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 +15 -5
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +5 -3
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +22 -12
- package/build/hooks/layout-child.cjs.map +3 -3
- package/build/hooks/layout.cjs +28 -13
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/line-height.cjs +1 -2
- package/build/hooks/line-height.cjs.map +2 -2
- package/build/hooks/states.cjs +27 -7
- package/build/hooks/states.cjs.map +3 -3
- package/build/hooks/style.cjs +31 -9
- package/build/hooks/style.cjs.map +3 -3
- package/build/hooks/text-align.cjs +36 -6
- package/build/hooks/text-align.cjs.map +3 -3
- package/build/hooks/typography.cjs +14 -5
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +14 -6
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +27 -19
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +0 -2
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +9 -5
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +11 -6
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +41 -3
- package/build/store/private-selectors.cjs.map +3 -3
- 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/block-bindings.cjs +29 -0
- package/build/utils/block-bindings.cjs.map +2 -2
- package/build/utils/dom.cjs +14 -0
- package/build/utils/dom.cjs.map +2 -2
- package/build/{components/rich-text/input-event.cjs → utils/native-undo.cjs} +29 -24
- 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-canvas/index.mjs +7 -2
- package/build-module/components/block-canvas/index.mjs.map +2 -2
- package/build-module/components/block-controls/groups.mjs +3 -1
- package/build-module/components/block-controls/groups.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs +11 -18
- package/build-module/components/block-edit/edit.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/block.mjs +9 -3
- package/build-module/components/block-list/block.mjs.map +3 -3
- package/build-module/components/block-list/index.mjs +1 -3
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +7 -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-first-element.mjs +9 -4
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +11 -4
- 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/index.mjs +43 -24
- package/build-module/components/block-toolbar/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-tools/index.mjs +7 -2
- package/build-module/components/block-tools/index.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/block-visibility/modal.mjs +22 -10
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +17 -7
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +18 -3
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +7 -1
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +5 -0
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +5 -1
- package/build-module/components/block-visibility/viewport-visibility-info.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/child-layout-control/index.mjs +0 -4
- package/build-module/components/child-layout-control/index.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-badges.mjs +41 -5
- package/build-module/components/global-styles/state-control-badges.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 -80
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +2 -4
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +33 -6
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +86 -18
- package/build-module/components/inserter/media-tab/media-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/keyboard-shortcuts/index.mjs +19 -11
- package/build-module/components/keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +1 -2
- 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/list-view/block.mjs +13 -4
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +0 -1
- package/build-module/components/media-placeholder/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/event-listeners/before-input-rules.mjs +8 -5
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +7 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +8 -3
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +8 -5
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +8 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +79 -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/typewriter/index.mjs +129 -136
- package/build-module/components/typewriter/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/use-block-commands/index.mjs +21 -17
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +2 -2
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +14 -1
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +43 -7
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +29 -3
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs +5 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
- package/build-module/components/writing-flow/use-drag-selection.mjs +1 -6
- package/build-module/components/writing-flow/use-drag-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 +54 -0
- package/build-module/components/writing-flow/use-editable-root.mjs.map +7 -0
- package/build-module/components/writing-flow/use-home-end.mjs +43 -0
- package/build-module/components/writing-flow/use-home-end.mjs.map +7 -0
- package/build-module/components/writing-flow/use-input.mjs +15 -5
- package/build-module/components/writing-flow/use-input.mjs.map +2 -2
- package/build-module/components/writing-flow/use-multi-selection.mjs +2 -2
- package/build-module/components/writing-flow/use-multi-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-select-all.mjs +19 -3
- package/build-module/components/writing-flow/use-select-all.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +134 -21
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +26 -1
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/hooks/background.mjs +14 -10
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/rich-text/index.mjs +2 -6
- package/build-module/hooks/block-fields/rich-text/index.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 +15 -5
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +5 -3
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +22 -12
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +28 -13
- package/build-module/hooks/layout.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/states.mjs +27 -7
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +40 -11
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/text-align.mjs +39 -10
- package/build-module/hooks/text-align.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +14 -5
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +14 -6
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +27 -19
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +0 -2
- package/build-module/layouts/grid.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 +12 -7
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +42 -3
- 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/block-bindings.mjs +28 -0
- package/build-module/utils/block-bindings.mjs.map +2 -2
- package/build-module/utils/dom.mjs +13 -0
- package/build-module/utils/dom.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 +14 -27
- package/build-style/content.css +14 -27
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +191 -61
- package/build-style/style.css +191 -61
- package/build-types/components/block-context/index.d.ts +7 -0
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/block-bindings.d.ts +19 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts +11 -0
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/get-px-from-css-unit.d.ts +2 -2
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -1
- package/build-types/utils/pasting.d.ts +1 -1
- package/build-types/utils/pasting.d.ts.map +1 -1
- package/package.json +43 -44
- 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-canvas/index.js +9 -2
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
- package/src/components/block-controls/groups.js +2 -0
- package/src/components/block-edit/edit.js +13 -31
- 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/block.js +6 -0
- package/src/components/block-list/content.scss +1 -11
- package/src/components/block-list/index.js +0 -2
- package/src/components/block-list/use-block-props/index.js +7 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +23 -4
- package/src/components/block-list/use-block-props/use-focus-handler.js +35 -9
- package/src/components/block-list/use-block-props/use-register-block-event-handlers.js +45 -0
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-manager/style.scss +1 -1
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-parent-selector/index.js +5 -2
- package/src/components/block-quick-navigation/style.scss +1 -3
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-toolbar/index.js +41 -18
- 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-tools/index.js +7 -0
- package/src/components/block-types-list/style.scss +0 -1
- 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/block-visibility/modal.js +24 -10
- package/src/components/block-visibility/style.scss +1 -1
- package/src/components/block-visibility/test/use-block-visibility.js +128 -35
- package/src/components/block-visibility/test/utils.js +11 -0
- package/src/components/block-visibility/use-block-visibility.js +33 -11
- package/src/components/block-visibility/utils.js +31 -6
- package/src/components/block-visibility/viewport-menu-item.js +10 -1
- package/src/components/block-visibility/viewport-toolbar.js +6 -0
- package/src/components/block-visibility/viewport-visibility-info.js +5 -1
- 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 +7 -9
- package/src/components/child-layout-control/index.js +0 -4
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -3
- 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/font-family/stories/index.story.jsx +1 -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-badges.js +45 -6
- package/src/components/global-styles/state-control.js +2 -2
- package/src/components/global-styles/style.scss +5 -0
- 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/state-control-badges.js +65 -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 -101
- package/src/components/image-editor/style.scss +33 -0
- package/src/components/image-size-control/index.js +0 -2
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/media-tab/hooks.js +55 -7
- package/src/components/inserter/media-tab/media-panel.js +117 -21
- package/src/components/inserter/media-tab/test/hooks.js +63 -0
- package/src/components/inserter/media-tab/test/media-panel.js +127 -0
- package/src/components/inserter/style.scss +19 -16
- package/src/components/inserter-list-item/style.scss +0 -15
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
- package/src/components/keyboard-shortcuts/index.js +28 -11
- package/src/components/line-height-control/index.js +1 -2
- package/src/components/link-control/index.js +7 -2
- package/src/components/link-control/style.scss +2 -2
- package/src/components/link-control/test/index.js +6 -6
- package/src/components/link-picker/style.scss +1 -2
- package/src/components/list-view/block.js +13 -4
- package/src/components/list-view/style.scss +4 -5
- package/src/components/media-placeholder/index.js +0 -1
- package/src/components/multi-selection-inspector/style.scss +1 -1
- 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/responsive-block-control/style.scss +1 -1
- package/src/components/rich-text/event-listeners/before-input-rules.js +8 -5
- package/src/components/rich-text/event-listeners/delete.js +7 -4
- package/src/components/rich-text/event-listeners/enter.js +10 -4
- package/src/components/rich-text/event-listeners/input-events.js +4 -3
- package/src/components/rich-text/event-listeners/input-rules.js +8 -5
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +4 -3
- package/src/components/rich-text/event-listeners/paste-handler.js +15 -3
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +4 -3
- package/src/components/rich-text/event-listeners/shortcuts.js +4 -3
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +4 -3
- package/src/components/rich-text/index.js +116 -26
- package/src/components/skip-to-selected-block/style.scss +1 -1
- 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/typewriter/index.js +228 -224
- package/src/components/url-input/index.js +363 -431
- package/src/components/url-input/test/index.js +592 -0
- package/src/components/use-block-commands/index.js +27 -17
- package/src/components/use-on-block-drop/index.js +2 -2
- package/src/components/warning/test/__snapshots__/index.js.snap +1 -1
- package/src/components/writing-flow/index.js +17 -1
- package/src/components/writing-flow/use-arrow-nav.js +90 -13
- package/src/components/writing-flow/use-click-selection.js +55 -5
- package/src/components/writing-flow/use-clipboard-handler.js +5 -2
- package/src/components/writing-flow/use-drag-selection.js +1 -14
- package/src/components/writing-flow/use-editable-root-event-handlers.js +266 -0
- package/src/components/writing-flow/use-editable-root.js +112 -0
- package/src/components/writing-flow/use-home-end.js +71 -0
- package/src/components/writing-flow/use-input.js +25 -8
- package/src/components/writing-flow/use-multi-selection.js +2 -3
- package/src/components/writing-flow/use-select-all.js +33 -3
- package/src/components/writing-flow/use-selection-observer.js +218 -42
- package/src/components/writing-flow/utils.js +62 -0
- package/src/hooks/background.js +27 -24
- package/src/hooks/block-fields/link/styles.scss +1 -6
- package/src/hooks/block-fields/media/styles.scss +1 -6
- package/src/hooks/block-fields/rich-text/index.js +6 -9
- 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 -4
- package/src/hooks/grid-visualizer.js +40 -36
- package/src/hooks/layout-child.js +19 -9
- package/src/hooks/layout.js +48 -31
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/states.js +38 -9
- package/src/hooks/style.js +67 -17
- package/src/hooks/test/inherited-value-wiring.js +411 -0
- package/src/hooks/test/preset-round-trip.js +456 -0
- package/src/hooks/test/style.js +29 -0
- package/src/hooks/test/text-align.js +34 -1
- package/src/hooks/text-align.js +41 -10
- package/src/hooks/typography.js +35 -24
- package/src/layouts/constrained.js +5 -1
- package/src/layouts/flex.js +5 -1
- package/src/layouts/grid.js +0 -2
- package/src/private-apis.js +11 -2
- package/src/store/actions.js +53 -19
- package/src/store/private-selectors.js +82 -6
- package/src/store/reducer.js +9 -9
- package/src/store/selectors.js +56 -8
- package/src/store/test/actions.js +1 -1
- package/src/store/test/private-selectors.js +271 -1
- package/src/style.scss +2 -0
- package/src/utils/block-bindings.ts +50 -0
- package/src/utils/dom.ts +33 -0
- package/src/utils/native-undo.js +56 -0
- package/src/utils/test/block-bindings.js +181 -0
- package/build/components/duotone/utils.cjs +0 -87
- package/build/components/duotone/utils.cjs.map +0 -7
- package/build/components/rich-text/input-event.cjs.map +0 -7
- package/build/components/rich-text/shortcut.cjs +0 -51
- package/build/components/rich-text/shortcut.cjs.map +0 -7
- package/build-module/components/duotone/utils.mjs +0 -59
- package/build-module/components/duotone/utils.mjs.map +0 -7
- package/build-module/components/rich-text/input-event.mjs +0 -25
- package/build-module/components/rich-text/input-event.mjs.map +0 -7
- package/build-module/components/rich-text/shortcut.mjs +0 -26
- package/build-module/components/rich-text/shortcut.mjs.map +0 -7
- package/src/components/duotone/utils.js +0 -90
- package/src/components/rich-text/input-event.js +0 -31
- package/src/components/rich-text/shortcut.js +0 -32
- package/src/hooks/test/get-variation-styles-with-ref-values.js +0 -91
|
@@ -34,6 +34,8 @@ function TextIndentControl({
|
|
|
34
34
|
withSlider = false,
|
|
35
35
|
hasBottomMargin = false,
|
|
36
36
|
help,
|
|
37
|
+
className,
|
|
38
|
+
placeholder,
|
|
37
39
|
...otherProps
|
|
38
40
|
}) {
|
|
39
41
|
const [availableUnits] = (0, import_use_settings.useSettings)("spacing.units");
|
|
@@ -64,7 +66,9 @@ function TextIndentControl({
|
|
|
64
66
|
__unstableInputWidth,
|
|
65
67
|
units,
|
|
66
68
|
onChange,
|
|
67
|
-
help
|
|
69
|
+
help,
|
|
70
|
+
className,
|
|
71
|
+
placeholder
|
|
68
72
|
}
|
|
69
73
|
);
|
|
70
74
|
}
|
|
@@ -81,7 +85,9 @@ function TextIndentControl({
|
|
|
81
85
|
onChange,
|
|
82
86
|
units,
|
|
83
87
|
__unstableInputWidth,
|
|
84
|
-
min: 0
|
|
88
|
+
min: 0,
|
|
89
|
+
className,
|
|
90
|
+
placeholder
|
|
85
91
|
}
|
|
86
92
|
) }),
|
|
87
93
|
withSlider && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalSpacer, { marginX: 2, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/text-indent-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalView as View,\n\tRangeControl,\n\t__experimentalSpacer as Spacer,\n\tFlex,\n\tFlexItem,\n\tBaseControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../components/use-settings';\n\n/**\n * Control for line text indent.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text indent.\n * @param {Function} props.onChange Handles change in text indent selection.\n * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.\n * @param {boolean} props.withSlider Whether to show the slider control.\n * @param {boolean} props.hasBottomMargin Whether to add bottom margin below the control.\n * @param {string} props.help Help text to display below the control.\n *\n * @return {Element} Text indent control.\n */\nexport default function TextIndentControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n\twithSlider = false,\n\thasBottomMargin = false,\n\thelp,\n\t...otherProps\n} ) {\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'ch',\n\t\t\t'%',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 16, em: 2, rem: 2, ch: 2 },\n\t} );\n\n\tconst [ valueQuantity, valueUnit ] = parseQuantityAndUnitFromRawValue(\n\t\tvalue,\n\t\tunits\n\t);\n\tconst isValueUnitRelative =\n\t\t!! valueUnit &&\n\t\t[ 'em', 'rem', '%', 'ch', 'vw', 'vh' ].includes( valueUnit );\n\n\tif ( ! withSlider ) {\n\t\treturn (\n\t\t\t<UnitControl\n\t\t\t\t{ ...otherProps }\n\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\tvalue={ value }\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\tunits={ units }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ help }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<View style={ hasBottomMargin ? { marginBottom: 12 } : undefined }>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Line indent' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t{ withSlider && (\n\t\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ valueQuantity }\n\t\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tif ( newValue === undefined ) {\n\t\t\t\t\t\t\t\t\t\tonChange?.( undefined );\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tonChange?.(\n\t\t\t\t\t\t\t\t\t\t\tnewValue + ( valueUnit ?? 'px' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\t\tmax={ isValueUnitRelative ? 10 : 100 }\n\t\t\t\t\t\t\t\tstep={ isValueUnitRelative ? 0.1 : 1 }\n\t\t\t\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t\t{ help && (\n\t\t\t\t<p className=\"components-base-control__help\">{ help }</p>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAUO;AACP,kBAAmB;AAKnB,0BAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalView as View,\n\tRangeControl,\n\t__experimentalSpacer as Spacer,\n\tFlex,\n\tFlexItem,\n\tBaseControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../components/use-settings';\n\n/**\n * Control for line text indent.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text indent.\n * @param {Function} props.onChange Handles change in text indent selection.\n * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.\n * @param {boolean} props.withSlider Whether to show the slider control.\n * @param {boolean} props.hasBottomMargin Whether to add bottom margin below the control.\n * @param {string} props.help Help text to display below the control.\n * @param {string} props.className Class name to add to the inner UnitControl.\n * @param {string} props.placeholder Placeholder for the inner UnitControl.\n *\n * @return {Element} Text indent control.\n */\nexport default function TextIndentControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n\twithSlider = false,\n\thasBottomMargin = false,\n\thelp,\n\tclassName,\n\tplaceholder,\n\t...otherProps\n} ) {\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'ch',\n\t\t\t'%',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 16, em: 2, rem: 2, ch: 2 },\n\t} );\n\n\tconst [ valueQuantity, valueUnit ] = parseQuantityAndUnitFromRawValue(\n\t\tvalue,\n\t\tunits\n\t);\n\tconst isValueUnitRelative =\n\t\t!! valueUnit &&\n\t\t[ 'em', 'rem', '%', 'ch', 'vw', 'vh' ].includes( valueUnit );\n\n\tif ( ! withSlider ) {\n\t\treturn (\n\t\t\t<UnitControl\n\t\t\t\t{ ...otherProps }\n\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\tvalue={ value }\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\tunits={ units }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ help }\n\t\t\t\tclassName={ className }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<View style={ hasBottomMargin ? { marginBottom: 12 } : undefined }>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Line indent' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t{ withSlider && (\n\t\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ valueQuantity }\n\t\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tif ( newValue === undefined ) {\n\t\t\t\t\t\t\t\t\t\tonChange?.( undefined );\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tonChange?.(\n\t\t\t\t\t\t\t\t\t\t\tnewValue + ( valueUnit ?? 'px' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\t\tmax={ isValueUnitRelative ? 10 : 100 }\n\t\t\t\t\t\t\t\tstep={ isValueUnitRelative ? 0.1 : 1 }\n\t\t\t\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t\t{ help && (\n\t\t\t\t<p className=\"components-base-control__help\">{ help }</p>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAUO;AACP,kBAAmB;AAKnB,0BAA4B;AAoDzB;AAnCY,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,uBAAuB;AAAA,EACvB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,CAAE,cAAe,QAAI,iCAAa,eAAgB;AACxD,QAAM,YAAQ,kBAAAA,8BAAgB;AAAA,IAC7B,gBAAgB,kBAAkB;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,eAAe,EAAE,IAAI,IAAI,IAAI,GAAG,KAAK,GAAG,IAAI,EAAE;AAAA,EAC/C,CAAE;AAEF,QAAM,CAAE,eAAe,SAAU,QAAI,kBAAAC;AAAA,IACpC;AAAA,IACA;AAAA,EACD;AACA,QAAM,sBACL,CAAC,CAAE,aACH,CAAE,MAAM,OAAO,KAAK,MAAM,MAAM,IAAK,EAAE,SAAU,SAAU;AAE5D,MAAK,CAAE,YAAa;AACnB,WACC;AAAA,MAAC,kBAAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACL,WAAQ,gBAAI,aAAc;AAAA,QAC1B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SACC,6CAAC,kBAAAC,oBAAA,EAAK,OAAQ,kBAAkB,EAAE,cAAc,GAAG,IAAI,QACtD;AAAA,gDAAC,8BAAY,aAAZ,EACE,8BAAI,aAAc,GACrB;AAAA,IACA,6CAAC,0BACA;AAAA,kDAAC,8BAAS,SAAO,MAChB;AAAA,QAAC,kBAAAD;AAAA,QAAA;AAAA,UACA,WAAQ,gBAAI,aAAc;AAAA,UAC1B,eAAc;AAAA,UACd,qBAAmB;AAAA,UACnB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,KAAM;AAAA,UACN;AAAA,UACA;AAAA;AAAA,MACD,GACD;AAAA,MACE,cACD,4CAAC,8BAAS,SAAO,MAChB,sDAAC,kBAAAE,sBAAA,EAAO,SAAU,GAAI,cAAe,GACpC;AAAA,QAAC;AAAA;AAAA,UACA,WAAQ,gBAAI,aAAc;AAAA,UAC1B,qBAAmB;AAAA,UACnB,OAAQ;AAAA,UACR,gBAAiB;AAAA,UACjB,UAAW,CAAE,aAAc;AAC1B,gBAAK,aAAa,QAAY;AAC7B,yBAAY,MAAU;AAAA,YACvB,OAAO;AACN;AAAA,gBACC,YAAa,aAAa;AAAA,cAC3B;AAAA,YACD;AAAA,UACD;AAAA,UACA,KAAM;AAAA,UACN,KAAM,sBAAsB,KAAK;AAAA,UACjC,MAAO,sBAAsB,MAAM;AAAA,UACnC,iBAAkB;AAAA;AAAA,MACnB,GACD,GACD;AAAA,OAEF;AAAA,IACE,QACD,4CAAC,OAAE,WAAU,iCAAkC,gBAAM;AAAA,KAEvD;AAEF;",
|
|
6
6
|
"names": ["useCustomUnits", "parseQuantityAndUnitFromRawValue", "UnitControl", "View", "Spacer"]
|
|
7
7
|
}
|
|
@@ -26,158 +26,151 @@ __export(typewriter_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(typewriter_exports);
|
|
27
27
|
var import_compose = require("@wordpress/compose");
|
|
28
28
|
var import_dom = require("@wordpress/dom");
|
|
29
|
-
var import_data = require("@wordpress/data");
|
|
30
29
|
var import_keycodes = require("@wordpress/keycodes");
|
|
31
|
-
var import_store = require("../../store/index.cjs");
|
|
32
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
31
|
var isIE = window.navigator.userAgent.indexOf("Trident") !== -1;
|
|
34
32
|
var arrowKeyCodes = /* @__PURE__ */ new Set([import_keycodes.UP, import_keycodes.DOWN, import_keycodes.LEFT, import_keycodes.RIGHT]);
|
|
35
33
|
var initialTriggerPercentage = 0.75;
|
|
36
34
|
function useTypewriter() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
return (0, import_compose.useRefEffect)((node) => {
|
|
36
|
+
const { ownerDocument } = node;
|
|
37
|
+
const { defaultView } = ownerDocument;
|
|
38
|
+
let scrollResizeRafId;
|
|
39
|
+
let onKeyDownRafId;
|
|
40
|
+
let caretRect;
|
|
41
|
+
function onScrollResize() {
|
|
42
|
+
if (scrollResizeRafId) {
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
scrollResizeRafId = defaultView.requestAnimationFrame(() => {
|
|
56
|
-
computeCaretRectangle();
|
|
57
|
-
scrollResizeRafId = null;
|
|
58
|
-
});
|
|
45
|
+
scrollResizeRafId = defaultView.requestAnimationFrame(() => {
|
|
46
|
+
computeCaretRectangle();
|
|
47
|
+
scrollResizeRafId = null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function onKeyDown(event) {
|
|
51
|
+
if (onKeyDownRafId) {
|
|
52
|
+
defaultView.cancelAnimationFrame(onKeyDownRafId);
|
|
59
53
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
onKeyDownRafId = defaultView.requestAnimationFrame(() => {
|
|
55
|
+
maintainCaretPosition(event);
|
|
56
|
+
onKeyDownRafId = null;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function maintainCaretPosition({ keyCode }) {
|
|
60
|
+
if (!isSelectionEligibleForScroll()) {
|
|
61
|
+
return;
|
|
68
62
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
const currentCaretRect = (0, import_dom.computeCaretRect)(defaultView);
|
|
74
|
-
if (!currentCaretRect) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (!caretRect) {
|
|
78
|
-
caretRect = currentCaretRect;
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (arrowKeyCodes.has(keyCode)) {
|
|
82
|
-
caretRect = currentCaretRect;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const diff = currentCaretRect.top - caretRect.top;
|
|
86
|
-
if (diff === 0) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const scrollContainer = (0, import_dom.getScrollContainer)(node);
|
|
90
|
-
if (!scrollContainer) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement;
|
|
94
|
-
const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
|
|
95
|
-
const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
|
|
96
|
-
const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY);
|
|
97
|
-
if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
|
|
98
|
-
caretRect = currentCaretRect;
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight;
|
|
102
|
-
if (
|
|
103
|
-
// The caret is under the lower fold.
|
|
104
|
-
caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
|
|
105
|
-
caretRect.top < scrollContainerY
|
|
106
|
-
) {
|
|
107
|
-
caretRect = currentCaretRect;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (windowScroll) {
|
|
111
|
-
defaultView.scrollBy(0, diff);
|
|
112
|
-
} else {
|
|
113
|
-
scrollContainer.scrollTop += diff;
|
|
114
|
-
}
|
|
63
|
+
const currentCaretRect = (0, import_dom.computeCaretRect)(defaultView);
|
|
64
|
+
if (!currentCaretRect) {
|
|
65
|
+
return;
|
|
115
66
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
computeCaretRectOnSelectionChange
|
|
120
|
-
);
|
|
67
|
+
if (!caretRect) {
|
|
68
|
+
caretRect = currentCaretRect;
|
|
69
|
+
return;
|
|
121
70
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
71
|
+
if (arrowKeyCodes.has(keyCode)) {
|
|
72
|
+
caretRect = currentCaretRect;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const diff = currentCaretRect.top - caretRect.top;
|
|
76
|
+
if (diff === 0) {
|
|
77
|
+
return;
|
|
128
78
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
79
|
+
const scrollContainer = (0, import_dom.getScrollContainer)(node);
|
|
80
|
+
if (!scrollContainer) {
|
|
81
|
+
return;
|
|
133
82
|
}
|
|
134
|
-
|
|
135
|
-
|
|
83
|
+
const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement;
|
|
84
|
+
const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
|
|
85
|
+
const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
|
|
86
|
+
const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY);
|
|
87
|
+
if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
|
|
88
|
+
caretRect = currentCaretRect;
|
|
89
|
+
return;
|
|
136
90
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
91
|
+
const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight;
|
|
92
|
+
if (
|
|
93
|
+
// The caret is under the lower fold.
|
|
94
|
+
caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
|
|
95
|
+
caretRect.top < scrollContainerY
|
|
96
|
+
) {
|
|
97
|
+
caretRect = currentCaretRect;
|
|
98
|
+
return;
|
|
143
99
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
100
|
+
if (windowScroll) {
|
|
101
|
+
defaultView.scrollBy(0, diff);
|
|
102
|
+
} else {
|
|
103
|
+
scrollContainer.scrollTop += diff;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function addSelectionChangeListener() {
|
|
107
|
+
ownerDocument.addEventListener(
|
|
108
|
+
"selectionchange",
|
|
109
|
+
computeCaretRectOnSelectionChange
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function computeCaretRectOnSelectionChange() {
|
|
113
|
+
ownerDocument.removeEventListener(
|
|
114
|
+
"selectionchange",
|
|
115
|
+
computeCaretRectOnSelectionChange
|
|
116
|
+
);
|
|
117
|
+
computeCaretRectangle();
|
|
118
|
+
}
|
|
119
|
+
function computeCaretRectangle() {
|
|
120
|
+
if (isSelectionEligibleForScroll()) {
|
|
121
|
+
caretRect = (0, import_dom.computeCaretRect)(defaultView);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function getActiveEditableElement() {
|
|
125
|
+
const { activeElement } = ownerDocument;
|
|
126
|
+
if (!activeElement) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (!activeElement.isContentEditable || !activeElement.contains(node)) {
|
|
130
|
+
return activeElement;
|
|
131
|
+
}
|
|
132
|
+
const { anchorNode } = defaultView.getSelection();
|
|
133
|
+
if (!anchorNode) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const element = anchorNode.nodeType === anchorNode.ELEMENT_NODE ? anchorNode : anchorNode.parentElement;
|
|
137
|
+
return element?.closest('[contenteditable="true"]') ?? null;
|
|
138
|
+
}
|
|
139
|
+
function isSelectionEligibleForScroll() {
|
|
140
|
+
const activeEditableElement = getActiveEditableElement();
|
|
141
|
+
return !!activeEditableElement && node.contains(activeEditableElement) && activeEditableElement.isContentEditable;
|
|
142
|
+
}
|
|
143
|
+
function isLastEditableNode() {
|
|
144
|
+
const editableNodes = node.querySelectorAll(
|
|
145
|
+
'[contenteditable="true"]'
|
|
146
|
+
);
|
|
147
|
+
const lastEditableNode = editableNodes[editableNodes.length - 1];
|
|
148
|
+
return lastEditableNode === getActiveEditableElement();
|
|
149
|
+
}
|
|
150
|
+
defaultView.addEventListener("scroll", onScrollResize, true);
|
|
151
|
+
defaultView.addEventListener("resize", onScrollResize, true);
|
|
152
|
+
node.addEventListener("keydown", onKeyDown);
|
|
153
|
+
node.addEventListener("keyup", maintainCaretPosition);
|
|
154
|
+
node.addEventListener("mousedown", addSelectionChangeListener);
|
|
155
|
+
node.addEventListener("touchstart", addSelectionChangeListener);
|
|
156
|
+
return () => {
|
|
157
|
+
defaultView.removeEventListener("scroll", onScrollResize, true);
|
|
158
|
+
defaultView.removeEventListener("resize", onScrollResize, true);
|
|
159
|
+
node.removeEventListener("keydown", onKeyDown);
|
|
160
|
+
node.removeEventListener("keyup", maintainCaretPosition);
|
|
161
|
+
node.removeEventListener("mousedown", addSelectionChangeListener);
|
|
162
|
+
node.removeEventListener(
|
|
163
|
+
"touchstart",
|
|
164
|
+
addSelectionChangeListener
|
|
165
|
+
);
|
|
166
|
+
ownerDocument.removeEventListener(
|
|
167
|
+
"selectionchange",
|
|
168
|
+
computeCaretRectOnSelectionChange
|
|
169
|
+
);
|
|
170
|
+
defaultView.cancelAnimationFrame(scrollResizeRafId);
|
|
171
|
+
defaultView.cancelAnimationFrame(onKeyDownRafId);
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
181
174
|
}
|
|
182
175
|
function Typewriter({ children }) {
|
|
183
176
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: useTypewriter(), className: "block-editor__typewriter", children });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/typewriter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,iBAAqD;AACrD,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\treturn useRefEffect( ( node ) => {\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\n\t\tlet scrollResizeRafId;\n\t\tlet onKeyDownRafId;\n\n\t\tlet caretRect;\n\n\t\tfunction onScrollResize() {\n\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t\tscrollResizeRafId = null;\n\t\t\t} );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t}\n\n\t\t\t// Use an animation frame for a smooth result.\n\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\tonKeyDownRafId = null;\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Maintains the scroll position after a selection change caused by a\n\t\t * keyboard event.\n\t\t *\n\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t */\n\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t// this be the position to be scrolled to in the future.\n\t\t\tif ( ! caretRect ) {\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t// now, let's disable it.\n\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\tif ( diff === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t// The page must be scrollable.\n\t\t\tif ( ! scrollContainer ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\tconst scrollY = windowScroll\n\t\t\t\t? defaultView.scrollY\n\t\t\t\t: scrollContainer.scrollTop;\n\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t? 0\n\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t// intentionally down.\n\t\t\tif (\n\t\t\t\tscrollY === 0 &&\n\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\tisLastEditableNode()\n\t\t\t) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t? defaultView.innerHeight\n\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t// view.\n\t\t\tif (\n\t\t\t\t// The caret is under the lower fold.\n\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t// The caret is above the upper fold.\n\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( windowScroll ) {\n\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t} else {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t * maintained.\n\t\t */\n\t\tfunction addSelectionChangeListener() {\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t */\n\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\townerDocument.removeEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\t\t\tcomputeCaretRectangle();\n\t\t}\n\n\t\t/**\n\t\t * Resets the scroll position to be maintained.\n\t\t */\n\t\tfunction computeCaretRectangle() {\n\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns the editable element owning the selection: the active\n\t\t * element, or, when a focused editing host contains the node\n\t\t * (a selected block supports `editableRoot`), the editable\n\t\t * element containing the selection.\n\t\t */\n\t\tfunction getActiveEditableElement() {\n\t\t\tconst { activeElement } = ownerDocument;\n\n\t\t\tif ( ! activeElement ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! activeElement.isContentEditable ||\n\t\t\t\t! activeElement.contains( node )\n\t\t\t) {\n\t\t\t\treturn activeElement;\n\t\t\t}\n\n\t\t\tconst { anchorNode } = defaultView.getSelection();\n\n\t\t\tif ( ! anchorNode ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst element =\n\t\t\t\tanchorNode.nodeType === anchorNode.ELEMENT_NODE\n\t\t\t\t\t? anchorNode\n\t\t\t\t\t: anchorNode.parentElement;\n\t\t\treturn element?.closest( '[contenteditable=\"true\"]' ) ?? null;\n\t\t}\n\n\t\t/**\n\t\t * Checks if the current situation is eligible for scroll:\n\t\t * - The component must contain the selection.\n\t\t * - The active element must be contenteditable.\n\t\t */\n\t\tfunction isSelectionEligibleForScroll() {\n\t\t\tconst activeEditableElement = getActiveEditableElement();\n\t\t\treturn (\n\t\t\t\t!! activeEditableElement &&\n\t\t\t\tnode.contains( activeEditableElement ) &&\n\t\t\t\tactiveEditableElement.isContentEditable\n\t\t\t);\n\t\t}\n\n\t\tfunction isLastEditableNode() {\n\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t);\n\t\t\tconst lastEditableNode = editableNodes[ editableNodes.length - 1 ];\n\t\t\treturn lastEditableNode === getActiveEditableElement();\n\t\t}\n\n\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t// reset.\n\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.removeEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.removeEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.removeEventListener(\n\t\t\t\t'touchstart',\n\t\t\t\taddSelectionChangeListener\n\t\t\t);\n\n\t\t\townerDocument.removeEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\n\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t};\n\t}, [] );\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,iBAAqD;AACrD,sBAAsC;AAuQpC;AArQF,IAAM,OAAO,OAAO,UAAU,UAAU,QAAS,SAAU,MAAM;AACjE,IAAM,gBAAgB,oBAAI,IAAK,CAAE,oBAAI,sBAAM,sBAAM,qBAAM,CAAE;AACzD,IAAM,2BAA2B;AAE1B,SAAS,gBAAgB;AAC/B,aAAO,6BAAc,CAAE,SAAU;AAChC,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AAExB,QAAI;AACJ,QAAI;AAEJ,QAAI;AAEJ,aAAS,iBAAiB;AACzB,UAAK,mBAAoB;AACxB;AAAA,MACD;AAEA,0BAAoB,YAAY,sBAAuB,MAAM;AAC5D,8BAAsB;AACtB,4BAAoB;AAAA,MACrB,CAAE;AAAA,IACH;AAEA,aAAS,UAAW,OAAQ;AAE3B,UAAK,gBAAiB;AACrB,oBAAY,qBAAsB,cAAe;AAAA,MAClD;AAGA,uBAAiB,YAAY,sBAAuB,MAAM;AACzD,8BAAuB,KAAM;AAC7B,yBAAiB;AAAA,MAClB,CAAE;AAAA,IACH;AAQA,aAAS,sBAAuB,EAAE,QAAQ,GAAI;AAC7C,UAAK,CAAE,6BAA6B,GAAI;AACvC;AAAA,MACD;AAEA,YAAM,uBAAmB,6BAAkB,WAAY;AAEvD,UAAK,CAAE,kBAAmB;AACzB;AAAA,MACD;AAIA,UAAK,CAAE,WAAY;AAClB,oBAAY;AACZ;AAAA,MACD;AAKA,UAAK,cAAc,IAAK,OAAQ,GAAI;AAEnC,oBAAY;AACZ;AAAA,MACD;AAEA,YAAM,OAAO,iBAAiB,MAAM,UAAU;AAE9C,UAAK,SAAS,GAAI;AACjB;AAAA,MACD;AAEA,YAAM,sBAAkB,+BAAoB,IAAK;AAGjD,UAAK,CAAE,iBAAkB;AACxB;AAAA,MACD;AAEA,YAAM,eACL,oBAAoB,cAAc,QAClC,oBAAoB,cAAc;AACnC,YAAM,UAAU,eACb,YAAY,UACZ,gBAAgB;AACnB,YAAM,mBAAmB,eACtB,IACA,gBAAgB,sBAAsB,EAAE;AAC3C,YAAM,yBAAyB,eAC5B,UAAU,MAAM,YAAY,eAC1B,UAAU,MAAM,qBAChB,YAAY,cAAc;AAQ/B,UACC,YAAY,KACZ,yBAAyB,4BACzB,mBAAmB,GAClB;AAED,oBAAY;AACZ;AAAA,MACD;AAEA,YAAM,wBAAwB,eAC3B,YAAY,cACZ,gBAAgB;AAInB;AAAA;AAAA,QAEC,UAAU,MAAM,UAAU,SACzB,mBAAmB;AAAA,QAEpB,UAAU,MAAM;AAAA,QACf;AAED,oBAAY;AACZ;AAAA,MACD;AAEA,UAAK,cAAe;AACnB,oBAAY,SAAU,GAAG,IAAK;AAAA,MAC/B,OAAO;AACN,wBAAgB,aAAa;AAAA,MAC9B;AAAA,IACD;AAMA,aAAS,6BAA6B;AACrC,oBAAc;AAAA,QACb;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAMA,aAAS,oCAAoC;AAC5C,oBAAc;AAAA,QACb;AAAA,QACA;AAAA,MACD;AACA,4BAAsB;AAAA,IACvB;AAKA,aAAS,wBAAwB;AAChC,UAAK,6BAA6B,GAAI;AACrC,wBAAY,6BAAkB,WAAY;AAAA,MAC3C;AAAA,IACD;AAQA,aAAS,2BAA2B;AACnC,YAAM,EAAE,cAAc,IAAI;AAE1B,UAAK,CAAE,eAAgB;AACtB,eAAO;AAAA,MACR;AAEA,UACC,CAAE,cAAc,qBAChB,CAAE,cAAc,SAAU,IAAK,GAC9B;AACD,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,WAAW,IAAI,YAAY,aAAa;AAEhD,UAAK,CAAE,YAAa;AACnB,eAAO;AAAA,MACR;AAEA,YAAM,UACL,WAAW,aAAa,WAAW,eAChC,aACA,WAAW;AACf,aAAO,SAAS,QAAS,0BAA2B,KAAK;AAAA,IAC1D;AAOA,aAAS,+BAA+B;AACvC,YAAM,wBAAwB,yBAAyB;AACvD,aACC,CAAC,CAAE,yBACH,KAAK,SAAU,qBAAsB,KACrC,sBAAsB;AAAA,IAExB;AAEA,aAAS,qBAAqB;AAC7B,YAAM,gBAAgB,KAAK;AAAA,QAC1B;AAAA,MACD;AACA,YAAM,mBAAmB,cAAe,cAAc,SAAS,CAAE;AACjE,aAAO,qBAAqB,yBAAyB;AAAA,IACtD;AAIA,gBAAY,iBAAkB,UAAU,gBAAgB,IAAK;AAC7D,gBAAY,iBAAkB,UAAU,gBAAgB,IAAK;AAE7D,SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,SAAS,qBAAsB;AACtD,SAAK,iBAAkB,aAAa,0BAA2B;AAC/D,SAAK,iBAAkB,cAAc,0BAA2B;AAEhE,WAAO,MAAM;AACZ,kBAAY,oBAAqB,UAAU,gBAAgB,IAAK;AAChE,kBAAY,oBAAqB,UAAU,gBAAgB,IAAK;AAEhE,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,SAAS,qBAAsB;AACzD,WAAK,oBAAqB,aAAa,0BAA2B;AAClE,WAAK;AAAA,QACJ;AAAA,QACA;AAAA,MACD;AAEA,oBAAc;AAAA,QACb;AAAA,QACA;AAAA,MACD;AAEA,kBAAY,qBAAsB,iBAAkB;AACpD,kBAAY,qBAAsB,cAAe;AAAA,IAClD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;AAEA,SAAS,WAAY,EAAE,SAAS,GAAI;AACnC,SACC,4CAAC,SAAI,KAAM,cAAc,GAAI,WAAU,4BACpC,UACH;AAEF;AASA,IAAM,uBAAuB,OAAO,CAAE,UAAW,MAAM,WAAW;AAOlE,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|