@wordpress/block-editor 15.23.0 → 16.0.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 +33 -0
- package/build/autocompleters/block.cjs +10 -2
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +0 -2
- package/build/components/background-image-control/index.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/edit-contents.cjs +3 -0
- package/build/components/block-inspector/edit-contents.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +2 -3
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-invalid-warning.cjs +8 -19
- package/build/components/block-list/block-invalid-warning.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 +3 -1
- 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 +12 -4
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-styles/use-styles-for-block.cjs +2 -1
- package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
- package/build/components/block-title/use-block-display-title.cjs +7 -2
- package/build/components/block-title/use-block-display-title.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
- package/build/components/block-toolbar/block-toolbar-icon.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-tools/index.cjs +7 -2
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +0 -1
- package/build/components/block-variation-transforms/index.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/child-layout-control/index.cjs +0 -6
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -5
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +0 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-appearance-control/index.cjs +6 -25
- package/build/components/font-appearance-control/index.cjs.map +3 -3
- package/build/components/font-family/index.cjs +6 -15
- package/build/components/font-family/index.cjs.map +3 -3
- package/build/components/font-sizes/font-size-picker.cjs +1 -2
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +0 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.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/typography-panel.cjs +4 -11
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/height-control/index.cjs +0 -2
- package/build/components/height-control/index.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs +0 -1
- package/build/components/html-element-control/index.cjs.map +2 -2
- package/build/components/image-editor/index.cjs +5 -0
- package/build/components/image-editor/index.cjs.map +3 -3
- package/build/components/image-editor/zoom-dropdown.cjs +0 -1
- package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs +3 -7
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs +107 -0
- package/build/components/inner-content/index.cjs.map +7 -0
- package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +67 -12
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-list.cjs +3 -1
- package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +287 -28
- package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs +32 -17
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-tab.cjs +26 -6
- package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
- package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
- package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
- package/build/components/inserter/no-results.cjs +2 -2
- package/build/components/inserter/no-results.cjs.map +2 -2
- package/build/components/inserter/preview-panel.cjs +2 -1
- package/build/components/inserter/preview-panel.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs +8 -2
- package/build/components/inserter-list-item/index.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/letter-spacing-control/index.cjs +0 -24
- package/build/components/letter-spacing-control/index.cjs.map +3 -3
- package/build/components/line-height-control/index.cjs +6 -22
- package/build/components/line-height-control/index.cjs.map +3 -3
- package/build/components/list-view/block-select-button.cjs +90 -84
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +61 -21
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/expander.cjs +1 -1
- package/build/components/list-view/expander.cjs.map +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
- package/build/components/list-view/use-list-view-client-ids.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/observe-typing/index.cjs +4 -3
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +1 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/resolution-tool/index.cjs +1 -2
- package/build/components/resolution-tool/index.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 +66 -17
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/text-alignment-control/index.cjs +0 -1
- package/build/components/text-alignment-control/index.cjs.map +2 -2
- package/build/components/text-decoration-control/index.cjs +0 -1
- package/build/components/text-decoration-control/index.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +0 -8
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/text-transform-control/index.cjs +0 -1
- package/build/components/text-transform-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/use-block-commands/index.cjs +21 -17
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -8
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +3 -7
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +12 -1
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +18 -5
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +2 -2
- 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.cjs +112 -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 +126 -20
- package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
- package/build/components/writing-flow/utils.cjs +39 -2
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/components/writing-mode-control/index.cjs +0 -1
- package/build/components/writing-mode-control/index.cjs.map +2 -2
- package/build/hooks/background.cjs +3 -2
- 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/elements.cjs +1 -1
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/font-size.cjs +1 -2
- package/build/hooks/font-size.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 +33 -16
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/position.cjs +36 -16
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +29 -12
- 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 +1 -1
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +35 -27
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +27 -22
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +51 -11
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +4 -1
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -0
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +85 -6
- package/build/store/private-selectors.cjs.map +3 -3
- package/build/store/selectors.cjs +13 -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-module/autocompleters/block.mjs +10 -2
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +0 -2
- package/build-module/components/background-image-control/index.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/edit-contents.mjs +4 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -3
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
- package/build-module/components/block-list/block-invalid-warning.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 +3 -1
- 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 +12 -4
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
- package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
- package/build-module/components/block-title/use-block-display-title.mjs +7 -2
- package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
- package/build-module/components/block-toolbar/block-toolbar-icon.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-tools/index.mjs +7 -2
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +0 -1
- package/build-module/components/block-variation-transforms/index.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/child-layout-control/index.mjs +0 -6
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -5
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-appearance-control/index.mjs +6 -15
- package/build-module/components/font-appearance-control/index.mjs.map +2 -2
- package/build-module/components/font-family/index.mjs +6 -15
- package/build-module/components/font-family/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +0 -1
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.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/typography-panel.mjs +4 -11
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/height-control/index.mjs +0 -2
- package/build-module/components/height-control/index.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +0 -1
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/image-editor/index.mjs +5 -0
- package/build-module/components/image-editor/index.mjs.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
- package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +3 -7
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs +82 -0
- package/build-module/components/inner-content/index.mjs.map +7 -0
- package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +66 -12
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
- package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +297 -32
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
- package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
- package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
- package/build-module/components/inserter/no-results.mjs +2 -2
- package/build-module/components/inserter/no-results.mjs.map +2 -2
- package/build-module/components/inserter/preview-panel.mjs +2 -1
- package/build-module/components/inserter/preview-panel.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs +8 -2
- package/build-module/components/inserter-list-item/index.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/letter-spacing-control/index.mjs +0 -14
- package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +6 -12
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +90 -84
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +61 -21
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/expander.mjs +1 -1
- package/build-module/components/list-view/expander.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.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/observe-typing/index.mjs +4 -3
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +1 -3
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/resolution-tool/index.mjs +1 -2
- package/build-module/components/resolution-tool/index.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 +64 -13
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/text-alignment-control/index.mjs +0 -1
- package/build-module/components/text-alignment-control/index.mjs.map +2 -2
- package/build-module/components/text-decoration-control/index.mjs +0 -1
- package/build-module/components/text-decoration-control/index.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +0 -8
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/text-transform-control/index.mjs +0 -1
- package/build-module/components/text-transform-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/use-block-commands/index.mjs +21 -17
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -8
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +4 -7
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +12 -1
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +19 -6
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +2 -2
- 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.mjs +86 -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 +128 -19
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +35 -1
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/components/writing-mode-control/index.mjs +0 -1
- package/build-module/components/writing-mode-control/index.mjs.map +2 -2
- package/build-module/hooks/background.mjs +3 -2
- 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/elements.mjs +1 -1
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/font-size.mjs +1 -2
- package/build-module/hooks/font-size.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 +32 -16
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +38 -18
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +29 -12
- 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 +1 -1
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +35 -27
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +27 -22
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +52 -11
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +5 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +3 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -0
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +84 -6
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +13 -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-style/content-rtl.css +15 -14
- package/build-style/content.css +15 -14
- 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 +144 -47
- package/build-style/style.css +144 -47
- 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 +46 -44
- package/src/autocompleters/block.js +10 -3
- package/src/autocompleters/test/block.js +53 -0
- package/src/components/background-image-control/index.js +0 -2
- package/src/components/block-canvas/index.js +9 -2
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-controls/groups.js +2 -0
- package/src/components/block-edit/edit.js +13 -31
- package/src/components/block-inspector/edit-contents.js +5 -1
- package/src/components/block-inspector/index.js +3 -2
- package/src/components/block-list/block-invalid-warning.js +8 -19
- package/src/components/block-list/block.js +6 -0
- package/src/components/block-list/index.js +0 -2
- package/src/components/block-list/use-block-props/index.js +2 -0
- 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 +34 -9
- 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-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-quick-navigation/style.scss +1 -3
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-styles/use-styles-for-block.js +1 -0
- package/src/components/block-title/use-block-display-title.js +7 -2
- package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
- package/src/components/block-toolbar/index.js +41 -18
- package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
- package/src/components/block-tools/index.js +7 -0
- package/src/components/block-types-list/style.scss +0 -1
- package/src/components/block-variation-transforms/index.js +0 -1
- 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/button-block-appender/content.scss +1 -7
- package/src/components/child-layout-control/index.js +0 -6
- package/src/components/color-palette/test/__snapshots__/control.js.snap +13 -108
- package/src/components/colors-gradients/control.js +4 -4
- package/src/components/colors-gradients/style.scss +2 -2
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +0 -1
- package/src/components/dimensions-tool/width-height-tool.js +0 -2
- package/src/components/font-appearance-control/index.js +6 -19
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +6 -19
- package/src/components/font-family/stories/index.story.jsx +1 -2
- package/src/components/font-sizes/font-size-picker.js +0 -1
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/state-control-badges.js +45 -6
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/global-styles/test/state-control-badges.js +65 -0
- package/src/components/global-styles/typography-panel.js +0 -7
- package/src/components/height-control/index.js +0 -2
- package/src/components/html-element-control/index.js +0 -1
- package/src/components/iframe/content.scss +3 -3
- package/src/components/image-editor/index.js +22 -0
- package/src/components/image-editor/zoom-dropdown.js +0 -1
- package/src/components/image-size-control/index.js +0 -4
- package/src/components/inner-content/index.js +119 -0
- package/src/components/inner-content/test/index.js +81 -0
- package/src/components/inserter/hooks/use-block-types-state.js +10 -2
- package/src/components/inserter/media-tab/hooks.js +114 -16
- package/src/components/inserter/media-tab/media-list.js +2 -0
- package/src/components/inserter/media-tab/media-panel.js +354 -19
- package/src/components/inserter/media-tab/media-preview.js +34 -17
- package/src/components/inserter/media-tab/media-tab.js +20 -2
- package/src/components/inserter/media-tab/test/hooks.js +267 -0
- package/src/components/inserter/media-tab/test/media-panel.js +127 -0
- package/src/components/inserter/mobile-tab-navigation.js +6 -1
- package/src/components/inserter/no-results.js +2 -2
- package/src/components/inserter/preview-panel.js +1 -0
- package/src/components/inserter/style.scss +115 -3
- package/src/components/inserter-list-item/index.js +8 -2
- package/src/components/inserter-list-item/style.scss +0 -15
- package/src/components/keyboard-shortcuts/index.js +28 -11
- package/src/components/letter-spacing-control/README.md +0 -8
- package/src/components/letter-spacing-control/index.js +5 -23
- package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +6 -16
- package/src/components/line-height-control/stories/index.story.jsx +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- 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/link-picker/test/index.js +3 -1
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +69 -23
- package/src/components/list-view/expander.js +5 -1
- package/src/components/list-view/style.scss +23 -5
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/media-placeholder/index.js +0 -1
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/observe-typing/index.js +9 -4
- package/src/components/preset-input-control/custom-value-controls.js +0 -2
- package/src/components/preset-input-control/index.js +0 -2
- package/src/components/resolution-tool/index.js +0 -1
- package/src/components/responsive-block-control/style.scss +1 -1
- package/src/components/responsive-block-control/test/index.js +1 -5
- 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 +94 -25
- package/src/components/skip-to-selected-block/style.scss +1 -1
- package/src/components/text-alignment-control/index.js +0 -1
- package/src/components/text-decoration-control/index.js +0 -1
- package/src/components/text-indent-control/index.js +7 -16
- package/src/components/text-transform-control/index.js +0 -1
- package/src/components/typewriter/index.js +228 -224
- package/src/components/use-block-commands/index.js +27 -17
- package/src/components/use-block-display-information/index.js +9 -13
- package/src/components/use-block-display-information/test/index.js +47 -9
- package/src/components/use-on-block-drop/index.js +4 -7
- package/src/components/writing-flow/index.js +15 -1
- package/src/components/writing-flow/use-arrow-nav.js +39 -12
- package/src/components/writing-flow/use-click-selection.js +2 -3
- 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.js +182 -0
- package/src/components/writing-flow/use-home-end.js +63 -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 +197 -38
- package/src/components/writing-flow/utils.js +83 -0
- package/src/components/writing-mode-control/index.js +0 -1
- package/src/hooks/background.js +7 -9
- 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-hooks.scss +15 -0
- package/src/hooks/elements.js +0 -1
- package/src/hooks/font-size.js +0 -1
- package/src/hooks/grid-visualizer.js +40 -36
- package/src/hooks/layout-child.js +19 -9
- package/src/hooks/layout.js +53 -35
- package/src/hooks/position.js +44 -23
- package/src/hooks/states.js +36 -13
- package/src/hooks/style.js +67 -17
- package/src/hooks/test/cross-origin-isolation.js +0 -4
- package/src/hooks/test/layout.js +75 -1
- 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 +0 -1
- package/src/layouts/constrained.js +56 -29
- package/src/layouts/flex.js +5 -4
- package/src/layouts/grid.js +59 -9
- package/src/layouts/test/constrained.js +91 -0
- package/src/layouts/test/grid.js +71 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +43 -14
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +166 -9
- package/src/store/selectors.js +41 -0
- package/src/store/test/actions.js +1 -1
- package/src/store/test/private-selectors.js +533 -0
- package/src/store/test/reducer.js +11 -11
- package/src/store/test/selectors.js +133 -0
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +50 -0
- package/src/utils/dom.ts +33 -0
- package/src/utils/test/block-bindings.js +181 -0
- package/build/components/rich-text/input-event.cjs +0 -50
- 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/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/rich-text/input-event.js +0 -31
- package/src/components/rich-text/shortcut.js +0 -32
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preset-input-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon as WCIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AAgL9B;AAjJa,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA,EACtB;AAAA,EACA,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,YAAQ;AAAA,IACb,UAAM,4CAA+B,WAAW,SAAS,UAAW;AAAA,IACpE,CAAE,WAAW,SAAS,UAAW;AAAA,EAClC;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAQ,Q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;AAAA,YACA,WAAU;AAAA,YACV;AAAA,YACA,MAAO;AAAA;AAAA,QACR;AAAA,SAEG,CAAE,cAAc,2BACnB;AAAA,UAAC,6BAAAC;AAAA,UAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,qBAAsB;AAAA,YACtB,2BAA4B;AAAA,YAC5B;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACD;AAAA,QAEC,cAAc,oBAAoB,CAAE,0BACrC;AAAA,UAAC;AAAA;AAAA,YACA,iBAAgB;AAAA,YAChB,kBAAiB,QAAS,YAAa,GAAG;AAAA,YAC1C,WAAU;AAAA,YACV,qBAAmB;AAAA,YACnB,iBAAkB;AAAA,YAClB,OAAQ;AAAA,YACR,KAAM,QAAQ,SAAS;AAAA,YACvB;AAAA,YACA,KAAM;AAAA,YACN,QAAS;AAAA,YACT,UAAW,CAAE,aACZ,SAAU,kBAAmB,QAAS,CAAE;AAAA,YAEzC,SAAU;AAAA,YACV,aAAc,CAAE,UAAW;AAG1B,oBAAM,YAAY,OAAO,aAAa,UAAU;AAChD,kBAAK,aAAa,UAAU,QAAY;AACvC,yBAAU,GAAI;AAAA,cACf;AAAA,YACD;AAAA,YACA;AAAA,YACA;AAAA,YACA,sBAAuB;AAAA,YACvB,MAAO;AAAA,YACP,OAAQ;AAAA,YACR,gBAAiB;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon as WCIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AAgL9B;AAjJa,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA,EAC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AAAA,YACA;AAAA,YACA;AAAA,YACA,sBAAuB;AAAA,YACvB,MAAO;AAAA,YACP,OAAQ;AAAA,YACR,gBAAiB;AAAA;AAAA,QAClB;AAAA,QAEC,cAAc,CAAE,oBAAoB,CAAE,0BACvC;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,qBAAmB;AAAA,YACnB,OAAQ;AAAA,YACR,QAAS;AAAA,YACT,UAAW,CAAE,cAAe;AAC3B,kBACC,+BACA,UAAU,aAAa,QAAQ,QAAQ,SAAS,GAC/C;AACD,0CAA2B,IAAK;AAAA,cACjC,OAAO;AACN;AAAA,kBACC;AAAA,oBACC,UAAU,aAAa;AAAA,oBACvB;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA;AAAA,cAGC,QAAQ;AAAA,gBACP,CAAE,WAAY,OAAO,QAAQ;AAAA,cAC9B,KAAK;AAAA;AAAA;AAAA,QAEP;AAAA,QAEC,cAAc,CAAE,uBACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,UAAW;AAAA,YACX,WAAY;AAAA,YACZ,OACC,6BACG,gBAAI,YAAa,QACjB,gBAAI,kBAAmB;AAAA,YAE3B,SAAU,MAAM;AACf,wCAA2B,CAAE,sBAAuB;AAAA,YACrD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": ["parseQuantityAndUnitFromRawValue", "HStack", "WCIcon", "CustomValueControls"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/resolution-tool/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tSelectControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\nconst DEFAULT_SIZE_OPTIONS = [\n\t{\n\t\tlabel: _x( 'Thumbnail', 'Image size option for resolution control' ),\n\t\tvalue: 'thumbnail',\n\t},\n\t{\n\t\tlabel: _x( 'Medium', 'Image size option for resolution control' ),\n\t\tvalue: 'medium',\n\t},\n\t{\n\t\tlabel: _x( 'Large', 'Image size option for resolution control' ),\n\t\tvalue: 'large',\n\t},\n\t{\n\t\tlabel: _x( 'Full Size', 'Image size option for resolution control' ),\n\t\tvalue: 'full',\n\t},\n];\n\nexport default function ResolutionTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SIZE_OPTIONS,\n\tdefaultValue = DEFAULT_SIZE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n\tresetAllFilter,\n} ) {\n\tconst displayValue = value ?? defaultValue;\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\toptions={ options }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ __( 'Select the size of the source image.' ) }\n\t\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,kBAAuB;AAwCpB;AAtCH,IAAM,uBAAuB;AAAA,EAC5B;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,UAAU,0CAA2C;AAAA,IAChE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,SAAS,0CAA2C;AAAA,IAC/D,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AACD;AAEe,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,eAAe,qBAAsB,CAAE,EAAE;AAAA,EACzC,mBAAmB;AAAA,EACnB;AACD,GAAI;AACH,QAAM,eAAe,SAAS;AAC9B,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,UAAW,MAAM,iBAAiB;AAAA,MAClC,WAAQ,gBAAI,YAAa;AAAA,MACzB,YAAa,MAAM,SAAU,YAAa;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,WAAQ,gBAAI,YAAa;AAAA,UACzB,OAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,UAAO,gBAAI,sCAAuC;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tSelectControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\nconst DEFAULT_SIZE_OPTIONS = [\n\t{\n\t\tlabel: _x( 'Thumbnail', 'Image size option for resolution control' ),\n\t\tvalue: 'thumbnail',\n\t},\n\t{\n\t\tlabel: _x( 'Medium', 'Image size option for resolution control' ),\n\t\tvalue: 'medium',\n\t},\n\t{\n\t\tlabel: _x( 'Large', 'Image size option for resolution control' ),\n\t\tvalue: 'large',\n\t},\n\t{\n\t\tlabel: _x( 'Full Size', 'Image size option for resolution control' ),\n\t\tvalue: 'full',\n\t},\n];\n\nexport default function ResolutionTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SIZE_OPTIONS,\n\tdefaultValue = DEFAULT_SIZE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n\tresetAllFilter,\n} ) {\n\tconst displayValue = value ?? defaultValue;\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\toptions={ options }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ __( 'Select the size of the source image.' ) }\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,kBAAuB;AAwCpB;AAtCH,IAAM,uBAAuB;AAAA,EAC5B;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,UAAU,0CAA2C;AAAA,IAChE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,SAAS,0CAA2C;AAAA,IAC/D,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AACD;AAEe,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,eAAe,qBAAsB,CAAE,EAAE;AAAA,EACzC,mBAAmB;AAAA,EACnB;AACD,GAAI;AACH,QAAM,eAAe,SAAS;AAC9B,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,UAAW,MAAM,iBAAiB;AAAA,MAClC,WAAQ,gBAAI,YAAa;AAAA,MACzB,YAAa,MAAM,SAAU,YAAa;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,WAAQ,gBAAI,YAAa;AAAA,UACzB,OAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,UAAO,gBAAI,sCAAuC;AAAA;AAAA,MACnD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["ToolsPanelItem"]
|
|
7
7
|
}
|
|
@@ -25,10 +25,9 @@ __export(before_input_rules_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(before_input_rules_exports);
|
|
26
26
|
var import_rich_text = require("@wordpress/rich-text");
|
|
27
27
|
var import_hooks = require("@wordpress/hooks");
|
|
28
|
-
var import_compose = require("@wordpress/compose");
|
|
29
28
|
var import_store = require("../../../store/index.cjs");
|
|
30
29
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
31
|
-
var {
|
|
30
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
32
31
|
var wrapSelectionSettings = ["`", '"', "'", "“”", "‘’"];
|
|
33
32
|
var before_input_rules_default = (props) => (element) => {
|
|
34
33
|
function onInput(event) {
|
|
@@ -70,10 +69,10 @@ var before_input_rules_default = (props) => (element) => {
|
|
|
70
69
|
const { defaultView } = ownerDocument;
|
|
71
70
|
const newEvent = new defaultView.InputEvent("input", init);
|
|
72
71
|
window.queueMicrotask(() => {
|
|
73
|
-
|
|
72
|
+
element.dispatchEvent(newEvent);
|
|
74
73
|
});
|
|
75
74
|
event.preventDefault();
|
|
76
75
|
}
|
|
77
|
-
return
|
|
76
|
+
return subscribeOwnedListener(element, "beforeinput", onInput, true);
|
|
78
77
|
};
|
|
79
78
|
//# sourceMappingURL=before-input-rules.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/before-input-rules.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tinsert,\n\tisCollapsed,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '“”', '‘’' ];\n\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tconst { inputType, data } = event;\n\t\tconst { value, onChange, registry } = props.current;\n\n\t\t// Only run the rules when inserting text.\n\t\tif ( inputType !== 'insertText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pair = applyFilters(\n\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\twrapSelectionSettings\n\t\t).find(\n\t\t\t( [ startChar, endChar ] ) => startChar === data || endChar === data\n\t\t);\n\n\t\tif ( ! pair ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\tconst start = value.start;\n\t\tconst end = value.end + startChar.length;\n\n\t\tlet newValue = insert( value, startChar, start, start );\n\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\t\tonChange( newValue );\n\t\t__unstableMarkAutomaticChange();\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tinit.data = endChar;\n\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t// Dispatch an `input` event with the new data. This will trigger the\n\t\t// input rules.\n\t\t// Postpone the `input` to the next event loop tick so that the dispatch\n\t\t// doesn't happen synchronously in the middle of `beforeinput` dispatch.\n\t\t// This is closer to how native `input` event would be timed, and also\n\t\t// makes sure that the `input` event is dispatched only after the `onChange`\n\t\t// call few lines above has fully updated the data store state and rerendered\n\t\t// all affected components.\n\t\twindow.queueMicrotask( () => {\n\t\t\telement.dispatchEvent( newEvent );\n\t\t} );\n\t\tevent.preventDefault();\n\t}\n\n\treturn subscribeOwnedListener( element, 'beforeinput', onInput, true );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAIO;AACP,mBAA6B;AAK7B,mBAA0C;AAC1C,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAS/D,IAAM,wBAAwB,CAAE,KAAK,KAAK,KAAK,MAAM,IAAK;AAE1D,IAAO,6BAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,UAAM,EAAE,WAAW,KAAK,IAAI;AAC5B,UAAM,EAAE,OAAO,UAAU,SAAS,IAAI,MAAM;AAG5C,QAAK,cAAc,cAAe;AACjC;AAAA,IACD;AAEA,YAAK,8BAAa,KAAM,GAAI;AAC3B;AAAA,IACD;AAEA,UAAM,WAAO;AAAA,MACZ;AAAA,MACA;AAAA,IACD,EAAE;AAAA,MACD,CAAE,CAAEC,YAAWC,QAAQ,MAAOD,eAAc,QAAQC,aAAY;AAAA,IACjE;AAEA,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AAEA,UAAM,CAAE,WAAW,UAAU,SAAU,IAAI;AAC3C,UAAM,QAAQ,MAAM;AACpB,UAAM,MAAM,MAAM,MAAM,UAAU;AAElC,QAAI,eAAW,yBAAQ,OAAO,WAAW,OAAO,KAAM;AACtD,mBAAW,yBAAQ,UAAU,SAAS,KAAK,GAAI;AAE/C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,IACD,IAAI,SAAS,SAAU,aAAAC,KAAiB;AAExC,yCAAqC;AACrC,aAAU,QAAS;AACnB,kCAA8B;AAE9B,UAAM,OAAO,CAAC;AAEd,eAAY,OAAO,OAAQ;AAC1B,WAAM,GAAI,IAAI,MAAO,GAAI;AAAA,IAC1B;AAEA,SAAK,OAAO;AAEZ,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,UAAM,WAAW,IAAI,YAAY,WAAY,SAAS,IAAK;AAU3D,WAAO,eAAgB,MAAM;AAC5B,cAAQ,cAAe,QAAS;AAAA,IACjC,CAAE;AACF,UAAM,eAAe;AAAA,EACtB;AAEA,SAAO,uBAAwB,SAAS,eAAe,SAAS,IAAK;AACtE;",
|
|
6
|
+
"names": ["richTextPrivateApis", "startChar", "endChar", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -25,9 +25,8 @@ __export(delete_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(delete_exports);
|
|
26
26
|
var import_keycodes = require("@wordpress/keycodes");
|
|
27
27
|
var import_rich_text = require("@wordpress/rich-text");
|
|
28
|
-
var import_compose = require("@wordpress/compose");
|
|
29
28
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
30
|
-
var {
|
|
29
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
31
30
|
var delete_default = (props) => (element) => {
|
|
32
31
|
function onKeyDown(event) {
|
|
33
32
|
const { keyCode } = event;
|
|
@@ -50,6 +49,6 @@ var delete_default = (props) => (element) => {
|
|
|
50
49
|
event.preventDefault();
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
|
-
return
|
|
52
|
+
return subscribeOwnedListener(element, "keydown", onKeyDown);
|
|
54
53
|
};
|
|
55
54
|
//# sourceMappingURL=delete.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/delete.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAkC;AAClC,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\nimport {\n\tisCollapsed,\n\tisEmpty,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { value, onMerge, onRemove } = props.current;\n\n\t\tif ( keyCode === DELETE || keyCode === BACKSPACE ) {\n\t\t\tconst { start, end, text } = value;\n\t\t\tconst isReverse = keyCode === BACKSPACE;\n\t\t\tconst hasActiveFormats =\n\t\t\t\tvalue.activeFormats && !! value.activeFormats.length;\n\n\t\t\t// Only process delete if the key press occurs at an uncollapsed edge.\n\t\t\tif (\n\t\t\t\t! isCollapsed( value ) ||\n\t\t\t\thasActiveFormats ||\n\t\t\t\t( isReverse && start !== 0 ) ||\n\t\t\t\t( ! isReverse && end !== text.length )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\telse if ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\treturn subscribeOwnedListener( element, 'keydown', onKeyDown );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAkC;AAClC,uBAIO;AAKP,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAE/D,IAAO,iBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,UAAW,OAAQ;AAC3B,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,OAAO,SAAS,SAAS,IAAI,MAAM;AAE3C,QAAK,YAAY,0BAAU,YAAY,2BAAY;AAClD,YAAM,EAAE,OAAO,KAAK,KAAK,IAAI;AAC7B,YAAM,YAAY,YAAY;AAC9B,YAAM,mBACL,MAAM,iBAAiB,CAAC,CAAE,MAAM,cAAc;AAG/C,UACC,KAAE,8BAAa,KAAM,KACrB,oBACE,aAAa,UAAU,KACvB,CAAE,aAAa,QAAQ,KAAK,QAC7B;AACD;AAAA,MACD;AAEA,UAAK,SAAU;AACd,gBAAS,CAAE,SAAU;AAAA,MACtB,WAMU,gBAAY,0BAAS,KAAM,KAAK,WAAY;AACrD,iBAAU,CAAE,SAAU;AAAA,MACvB;AAEA,YAAM,eAAe;AAAA,IACtB;AAAA,EACD;AAEA,SAAO,uBAAwB,SAAS,WAAW,SAAU;AAC9D;",
|
|
6
|
+
"names": ["richTextPrivateApis"]
|
|
7
7
|
}
|
|
@@ -27,6 +27,7 @@ var import_keycodes = require("@wordpress/keycodes");
|
|
|
27
27
|
var import_rich_text = require("@wordpress/rich-text");
|
|
28
28
|
var import_compose = require("@wordpress/compose");
|
|
29
29
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
30
|
+
var { subscribeOwnedListener, ownsSelection } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
30
31
|
var { subscribeDelegatedListener } = (0, import_lock_unlock.unlock)(import_compose.privateApis);
|
|
31
32
|
var enter_default = (props) => (element) => {
|
|
32
33
|
function onKeyDownDeprecated(event) {
|
|
@@ -42,7 +43,7 @@ var enter_default = (props) => (element) => {
|
|
|
42
43
|
if (event.defaultPrevented) {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
|
-
if (event.target !== element) {
|
|
46
|
+
if (event.target !== element && !ownsSelection(element)) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
if (event.keyCode !== import_keycodes.ENTER) {
|
|
@@ -86,7 +87,7 @@ var enter_default = (props) => (element) => {
|
|
|
86
87
|
"keydown",
|
|
87
88
|
onKeyDown
|
|
88
89
|
);
|
|
89
|
-
const unsubscribeKeyDownDeprecated =
|
|
90
|
+
const unsubscribeKeyDownDeprecated = subscribeOwnedListener(
|
|
90
91
|
element,
|
|
91
92
|
"keydown",
|
|
92
93
|
onKeyDownDeprecated,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/enter.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ENTER } from '@wordpress/keycodes';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAsB;AACtB,
|
|
6
|
-
"names": ["composePrivateApis"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ENTER } from '@wordpress/keycodes';\nimport {\n\tinsert,\n\tremove,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener, ownsSelection } = unlock( richTextPrivateApis );\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDownDeprecated( event ) {\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { onReplace, onSplit } = props.current;\n\n\t\tif ( onReplace && onSplit ) {\n\t\t\tevent.__deprecatedOnSplit = true;\n\t\t}\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element, or whether the element owns the\n\t\t// selection through a focused editing host.\n\t\tif ( event.target !== element && ! ownsSelection( element ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tdisableLineBreaks,\n\t\t\tonSplitAtEnd,\n\t\t\tonSplitAtDoubleLineEnd,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\tevent.preventDefault();\n\n\t\tconst { text, start, end } = value;\n\n\t\tif ( event.shiftKey ) {\n\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t}\n\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\tonSplitAtEnd();\n\t\t} else if (\n\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t// block when there are two line breaks at the end of the\n\t\t\t// block, so triple Enter exits the block.\n\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\tstart === end &&\n\t\t\tend === text.length &&\n\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tconst _value = { ...value };\n\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\tonChange( remove( _value ) );\n\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t} );\n\t\t} else if ( ! disableLineBreaks ) {\n\t\t\tonChange( insert( value, '\\n' ) );\n\t\t}\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tconst unsubscribeKeyDown = subscribeDelegatedListener(\n\t\tdefaultView,\n\t\t'keydown',\n\t\tonKeyDown\n\t);\n\t// Capture phase so this runs before ancestor (writing flow) bubble\n\t// handlers, matching the timing of the previous raw element listener.\n\tconst unsubscribeKeyDownDeprecated = subscribeOwnedListener(\n\t\telement,\n\t\t'keydown',\n\t\tonKeyDownDeprecated,\n\t\ttrue\n\t);\n\treturn () => {\n\t\tunsubscribeKeyDown();\n\t\tunsubscribeKeyDownDeprecated();\n\t};\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAsB;AACtB,uBAIO;AACP,qBAAkD;AAKlD,yBAAuB;AAEvB,IAAM,EAAE,wBAAwB,cAAc,QAAI,2BAAQ,iBAAAA,WAAoB;AAC9E,IAAM,EAAE,2BAA2B,QAAI,2BAAQ,eAAAC,WAAmB;AAElE,IAAO,gBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,oBAAqB,OAAQ;AACrC,QAAK,MAAM,YAAY,uBAAQ;AAC9B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,QAAQ,IAAI,MAAM;AAErC,QAAK,aAAa,SAAU;AAC3B,YAAM,sBAAsB;AAAA,IAC7B;AAAA,EACD;AAEA,WAAS,UAAW,OAAQ;AAC3B,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAKA,QAAK,MAAM,WAAW,WAAW,CAAE,cAAe,OAAQ,GAAI;AAC7D;AAAA,IACD;AAEA,QAAK,MAAM,YAAY,uBAAQ;AAC9B;AAAA,IACD;AAEA,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAEV,UAAM,eAAe;AAErB,UAAM,EAAE,MAAM,OAAO,IAAI,IAAI;AAE7B,QAAK,MAAM,UAAW;AACrB,UAAK,CAAE,mBAAoB;AAC1B,qBAAU,yBAAQ,OAAO,IAAK,CAAE;AAAA,MACjC;AAAA,IACD,WAAY,gBAAgB,UAAU,OAAO,QAAQ,KAAK,QAAS;AAClE,mBAAa;AAAA,IACd;AAAA;AAAA;AAAA;AAAA,MAIC,0BACA,UAAU,OACV,QAAQ,KAAK,UACb,KAAK,MAAO,EAAG,MAAM;AAAA,MACpB;AACD,eAAS,MAAO,MAAM;AACrB,cAAM,SAAS,EAAE,GAAG,MAAM;AAC1B,eAAO,QAAQ,OAAO,MAAM;AAC5B,qBAAU,yBAAQ,MAAO,CAAE;AAC3B,+BAAuB;AAAA,MACxB,CAAE;AAAA,IACH,WAAY,CAAE,mBAAoB;AACjC,mBAAU,yBAAQ,OAAO,IAAK,CAAE;AAAA,IACjC;AAAA,EACD;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,QAAM,qBAAqB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAGA,QAAM,+BAA+B;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO,MAAM;AACZ,uBAAmB;AACnB,iCAA6B;AAAA,EAC9B;AACD;",
|
|
6
|
+
"names": ["richTextPrivateApis", "composePrivateApis"]
|
|
7
7
|
}
|
|
@@ -23,9 +23,9 @@ __export(input_events_exports, {
|
|
|
23
23
|
default: () => input_events_default
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(input_events_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
27
27
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
28
|
-
var {
|
|
28
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
29
29
|
var input_events_default = (props) => (element) => {
|
|
30
30
|
const { inputEvents } = props.current;
|
|
31
31
|
function onInput(event) {
|
|
@@ -33,6 +33,6 @@ var input_events_default = (props) => (element) => {
|
|
|
33
33
|
keyboardShortcut(event);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return subscribeOwnedListener(element, "input", onInput);
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=input-events.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/input-events.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\n\nimport { privateApis as richTextPrivateApis } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tconst { inputEvents } = props.current;\n\tfunction onInput( event ) {\n\t\tfor ( const keyboardShortcut of inputEvents.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\treturn subscribeOwnedListener( element, 'input', onInput );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAmD;AAKnD,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAE/D,IAAO,uBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,QAAM,EAAE,YAAY,IAAI,MAAM;AAC9B,WAAS,QAAS,OAAQ;AACzB,eAAY,oBAAoB,YAAY,SAAU;AACrD,uBAAkB,KAAM;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,uBAAwB,SAAS,SAAS,OAAQ;AAC1D;",
|
|
6
|
+
"names": ["richTextPrivateApis"]
|
|
7
7
|
}
|
|
@@ -26,12 +26,11 @@ __export(input_rules_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(input_rules_exports);
|
|
27
27
|
var import_rich_text = require("@wordpress/rich-text");
|
|
28
28
|
var import_blocks = require("@wordpress/blocks");
|
|
29
|
-
var import_compose = require("@wordpress/compose");
|
|
30
29
|
var import_store = require("../../../store/index.cjs");
|
|
31
30
|
var import_prevent_event_discovery = require("../prevent-event-discovery.cjs");
|
|
32
31
|
var import_selection = require("../../../utils/selection.cjs");
|
|
33
32
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
34
|
-
var {
|
|
33
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
35
34
|
function findSelection(blocks) {
|
|
36
35
|
let i = blocks.length;
|
|
37
36
|
while (i--) {
|
|
@@ -133,13 +132,13 @@ var input_rules_default = (props) => (element) => {
|
|
|
133
132
|
__unstableMarkAutomaticChange();
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
|
-
const unsubscribeInput =
|
|
135
|
+
const unsubscribeInput = subscribeOwnedListener(
|
|
137
136
|
element,
|
|
138
137
|
"input",
|
|
139
138
|
onInput,
|
|
140
139
|
true
|
|
141
140
|
);
|
|
142
|
-
const unsubscribeCompositionEnd =
|
|
141
|
+
const unsubscribeCompositionEnd = subscribeOwnedListener(
|
|
143
142
|
element,
|
|
144
143
|
"compositionend",
|
|
145
144
|
onInput,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/input-rules.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tinsert,\n\ttoHTMLString,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\nexport function findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport default ( props ) => ( element ) => {\n\tfunction inputRule() {\n\t\tconst { getValue, onReplace, selectionChange, registry } =\n\t\t\tprops.current;\n\n\t\tif ( ! onReplace ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We must use getValue() here because value may be update\n\t\t// asynchronously.\n\t\tconst value = getValue();\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// The character right before the caret must be a plain space.\n\t\tif ( characterBefore !== ' ' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( { type } ) => type === 'prefix'\n\t\t);\n\t\tconst transformation = findTransform(\n\t\t\tprefixTransforms,\n\t\t\t( { prefix } ) => {\n\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t}\n\t\t);\n\n\t\tif ( ! transformation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst content = toHTMLString( {\n\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t} );\n\t\tconst block = transformation.transform( content );\n\n\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\tonReplace( [ block ] );\n\t\tregistry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();\n\n\t\treturn true;\n\t}\n\n\tfunction onInput( event ) {\n\t\tconst { inputType, type } = event;\n\t\tconst {\n\t\t\tgetValue,\n\t\t\tonChange,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\tformatTypes,\n\t\t\tregistry,\n\t\t\tonReplace,\n\t\t} = props.current;\n\n\t\t// Only run input rules when inserting text.\n\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = getValue();\n\n\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( transform ) => transform.type === 'input'\n\t\t);\n\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\treturn item.regExp.test( value.text );\n\t\t} );\n\n\t\tif ( transformation ) {\n\t\t\tonReplace( transformation.transform() );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkAutomaticChange();\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformed = formatTypes.reduce(\n\t\t\t( accumulator, { __unstableInputRule } ) => {\n\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\taccumulator = __unstableInputRule( accumulator );\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\tpreventEventDiscovery( value )\n\t\t);\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\tif ( transformed !== value ) {\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( {\n\t\t\t\t...transformed,\n\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t} );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\t}\n\n\t// Capture phase so these run before ancestor (writing flow) bubble\n\t// handlers, matching the timing of the previous raw element listeners.\n\tconst unsubscribeInput = subscribeOwnedListener(\n\t\telement,\n\t\t'input',\n\t\tonInput,\n\t\ttrue\n\t);\n\tconst unsubscribeCompositionEnd = subscribeOwnedListener(\n\t\telement,\n\t\t'compositionend',\n\t\tonInput,\n\t\ttrue\n\t);\n\treturn () => {\n\t\tunsubscribeInput();\n\t\tunsubscribeCompositionEnd();\n\t};\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAIO;AACP,oBAAkD;AAKlD,mBAA0C;AAC1C,qCAAsC;AACtC,uBAGO;AACP,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAExD,SAAS,cAAe,QAAS;AACvC,MAAI,IAAI,OAAO;AAEf,SAAQ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AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO,MAAM;AACZ,qBAAiB;AACjB,8BAA0B;AAAA,EAC3B;AACD;",
|
|
6
|
+
"names": ["richTextPrivateApis", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -23,10 +23,10 @@ __export(insert_replacement_text_exports, {
|
|
|
23
23
|
default: () => insert_replacement_text_default
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(insert_replacement_text_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
27
27
|
var import_store = require("../../../store/index.cjs");
|
|
28
28
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
29
|
-
var {
|
|
29
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
30
30
|
var insert_replacement_text_default = (props) => (element) => {
|
|
31
31
|
function onInput(event) {
|
|
32
32
|
if (event.inputType !== "insertReplacementText") {
|
|
@@ -35,6 +35,6 @@ var insert_replacement_text_default = (props) => (element) => {
|
|
|
35
35
|
const { registry } = props.current;
|
|
36
36
|
registry.dispatch(import_store.store).__unstableMarkLastChangeAsPersistent();
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return subscribeOwnedListener(element, "beforeinput", onInput);
|
|
39
39
|
};
|
|
40
40
|
//# sourceMappingURL=insert-replacement-text.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/insert-replacement-text.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\n\nimport { privateApis as richTextPrivateApis } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\n/**\n * When the browser is about to auto correct, add an undo level so the user can\n * revert the change.\n *\n * @param {Object} props\n */\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tif ( event.inputType !== 'insertReplacementText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { registry } = props.current;\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t}\n\n\treturn subscribeOwnedListener( element, 'beforeinput', onInput );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAmD;AAKnD,mBAA0C;AAC1C,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAQ/D,IAAO,kCAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,QAAK,MAAM,cAAc,yBAA0B;AAClD;AAAA,IACD;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM;AAC3B,aACE,SAAU,aAAAC,KAAiB,EAC3B,qCAAqC;AAAA,EACxC;AAEA,SAAO,uBAAwB,SAAS,eAAe,OAAQ;AAChE;",
|
|
6
|
+
"names": ["richTextPrivateApis", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -32,6 +32,7 @@ var import_utils = require("../utils.cjs");
|
|
|
32
32
|
var import_pasting = require("../../../utils/pasting.cjs");
|
|
33
33
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
34
34
|
var { subscribeDelegatedListener } = (0, import_lock_unlock.unlock)(import_compose.privateApis);
|
|
35
|
+
var { ownsSelection } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
35
36
|
var paste_handler_default = (props) => (element) => {
|
|
36
37
|
function _onPaste(event) {
|
|
37
38
|
const {
|
|
@@ -46,7 +47,7 @@ var paste_handler_default = (props) => (element) => {
|
|
|
46
47
|
pastePlainText,
|
|
47
48
|
registry
|
|
48
49
|
} = props.current;
|
|
49
|
-
if (!element.contains(event.target)) {
|
|
50
|
+
if (!element.contains(event.target) && !ownsSelection(element)) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
if (event.defaultPrevented) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/paste-handler.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,
|
|
6
|
-
"names": ["composePrivateApis", "content", "blockEditorStore"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\nconst { ownsSelection } = unlock( richTextPrivateApis );\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element. When the editable\n\t\t// wrapper holds focus (the selected block supports `editableRoot`),\n\t\t// the event targets the wrapper instead; the element then owns the\n\t\t// paste when it contains the selection.\n\t\tif (\n\t\t\t! element.contains( event.target ) &&\n\t\t\t! ownsSelection( element )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL → block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\treturn subscribeDelegatedListener( defaultView, 'paste', _onPaste );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,uBAKO;AACP,iBAAsB;AACtB,qBAAkD;AAKlD,mB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E;AAAA,MAC1C;AAAA,IACD;AAKA,QAAK,YAAa;AACjB,kBAAa,IAAK;AAClB;AAAA,IACD;AAEA,QAAK,gBAAiB;AACrB,mBAAU,yBAAQ,WAAO,yBAAQ,EAAE,MAAM,UAAU,CAAE,CAAE,CAAE;AACzD;AAAA,IACD;AAEA,QAAI,OAAO;AAEX,UAAM,mBAAmB,UAAU,KAAK;AAExC,QACC,iCACA,0BAAS,KAAM,SACf,kBAAO,gBAAiB;AAAA,IAExB,WAAW,KAAM,gBAAiB,GACjC;AACD,aAAO;AAAA,IACR;AAEA,UAAM,cAAU,4BAAc;AAAA,MAC7B,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAK,OAAO,YAAY,UAAW;AAClC,kBAAa,OAAQ;AACrB;AAAA,IACD;AAEA,QAAK,CAAE,QAAQ,UAAU,CAAE,aAAa,KAAE,0BAAS,KAAM,GAAI;AAC5D;AAAA,IACD;AAIA,QAAK,SAAS,UAAW;AACxB,kBAAa,IAAK;AAClB,eACE,SAAU,aAAAC,KAAiB,EAC3B,qCAAqC;AAAA,IACxC;AAEA,cAAW,SAAS,QAAQ,SAAS,GAAG,EAAG;AAAA,EAC5C;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,SAAO,2BAA4B,aAAa,SAAS,QAAS;AACnE;",
|
|
6
|
+
"names": ["composePrivateApis", "richTextPrivateApis", "content", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -24,15 +24,15 @@ __export(remove_browser_shortcuts_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(remove_browser_shortcuts_exports);
|
|
26
26
|
var import_keycodes = require("@wordpress/keycodes");
|
|
27
|
-
var
|
|
27
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
28
28
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
29
|
-
var {
|
|
29
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
30
30
|
var remove_browser_shortcuts_default = () => (node) => {
|
|
31
31
|
function onKeydown(event) {
|
|
32
32
|
if (import_keycodes.isKeyboardEvent.primary(event, "z") || import_keycodes.isKeyboardEvent.primary(event, "y") || import_keycodes.isKeyboardEvent.primaryShift(event, "z")) {
|
|
33
33
|
event.preventDefault();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return subscribeOwnedListener(node, "keydown", onKeydown, true);
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=remove-browser-shortcuts.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/remove-browser-shortcuts.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isKeyboardEvent } from '@wordpress/keycodes';\nimport { privateApis as
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAgC;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\nimport { privateApis as richTextPrivateApis } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\n/**\n * Hook to prevent default behaviors for key combinations otherwise handled\n * internally by RichText.\n */\nexport default () => ( node ) => {\n\tfunction onKeydown( event ) {\n\t\tif (\n\t\t\tisKeyboardEvent.primary( event, 'z' ) ||\n\t\t\tisKeyboardEvent.primary( event, 'y' ) ||\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' )\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\treturn subscribeOwnedListener( node, 'keydown', onKeydown, true );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAgC;AAEhC,uBAAmD;AAKnD,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAM/D,IAAO,mCAAQ,MAAM,CAAE,SAAU;AAChC,WAAS,UAAW,OAAQ;AAC3B,QACC,gCAAgB,QAAS,OAAO,GAAI,KACpC,gCAAgB,QAAS,OAAO,GAAI,KACpC,gCAAgB,aAAc,OAAO,GAAI,GACxC;AACD,YAAM,eAAe;AAAA,IACtB;AAAA,EACD;AACA,SAAO,uBAAwB,MAAM,WAAW,WAAW,IAAK;AACjE;",
|
|
6
|
+
"names": ["richTextPrivateApis"]
|
|
7
7
|
}
|
|
@@ -23,9 +23,9 @@ __export(shortcuts_exports, {
|
|
|
23
23
|
default: () => shortcuts_default
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(shortcuts_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
27
27
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
28
|
-
var {
|
|
28
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
29
29
|
var shortcuts_default = (props) => (element) => {
|
|
30
30
|
const { keyboardShortcuts } = props.current;
|
|
31
31
|
function onKeyDown(event) {
|
|
@@ -33,6 +33,6 @@ var shortcuts_default = (props) => (element) => {
|
|
|
33
33
|
keyboardShortcut(event);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return subscribeOwnedListener(element, "keydown", onKeyDown, true);
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=shortcuts.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/shortcuts.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\n\nimport { privateApis as richTextPrivateApis } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tconst { keyboardShortcuts } = props.current;\n\tfunction onKeyDown( event ) {\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\treturn subscribeOwnedListener( element, 'keydown', onKeyDown, true );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAmD;AAKnD,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,iBAAAA,WAAoB;AAE/D,IAAO,oBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,QAAM,EAAE,kBAAkB,IAAI,MAAM;AACpC,WAAS,UAAW,OAAQ;AAC3B,eAAY,oBAAoB,kBAAkB,SAAU;AAC3D,uBAAkB,KAAM;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,uBAAwB,SAAS,WAAW,WAAW,IAAK;AACpE;",
|
|
6
|
+
"names": ["richTextPrivateApis"]
|
|
7
7
|
}
|
|
@@ -24,10 +24,10 @@ __export(undo_automatic_change_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(undo_automatic_change_exports);
|
|
26
26
|
var import_keycodes = require("@wordpress/keycodes");
|
|
27
|
-
var
|
|
27
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
28
28
|
var import_store = require("../../../store/index.cjs");
|
|
29
29
|
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
30
|
-
var {
|
|
30
|
+
var { subscribeOwnedListener } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
31
31
|
var undo_automatic_change_default = (props) => (element) => {
|
|
32
32
|
function onKeyDown(event) {
|
|
33
33
|
const { keyCode } = event;
|
|
@@ -49,6 +49,6 @@ var undo_automatic_change_default = (props) => (element) => {
|
|
|
49
49
|
event.preventDefault();
|
|
50
50
|
__experimentalUndo();
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return subscribeOwnedListener(element, "keydown", onKeyDown);
|
|
53
53
|
};
|
|
54
54
|
//# sourceMappingURL=undo-automatic-change.cjs.map
|