@wordpress/block-editor 9.0.0 → 9.3.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 +10 -0
- package/README.md +1 -0
- package/build/autocompleters/block.js +3 -1
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +4 -13
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-content-overlay/index.js +4 -82
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-context/index.js.map +1 -1
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +65 -0
- package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +488 -0
- package/build/components/block-draggable/index.native.js.map +1 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build/components/block-list/block-list-context.native.js +195 -0
- package/build/components/block-list/block-list-context.native.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +67 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build/components/block-list/block-list-item.native.js +12 -9
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +27 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +34 -32
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +75 -23
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -4
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +10 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.native.js +17 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +1 -1
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +19 -8
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +5 -16
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +3 -7
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +6 -3
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +6 -3
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/menu-items.js +3 -7
- package/build/components/block-styles/menu-items.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-toolbar/utils.js +5 -8
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -0
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -29
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +16 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +10 -3
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +122 -41
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +22 -5
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/copy-handler/index.js +17 -1
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-block-appender/index.native.js.map +1 -1
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +51 -50
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +3 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-size-control/index.js +3 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +31 -13
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +3 -7
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/no-results.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +1 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inspector-popover-header/index.js +56 -0
- package/build/components/inspector-popover-header/index.js.map +1 -0
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/constants.js +11 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/index.js +4 -4
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-create-button.js +1 -3
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-input.js +5 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-results.js +4 -3
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +3 -7
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +4 -4
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +0 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +1 -7
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.js +4 -6
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +20 -7
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +10 -4
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +62 -7
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +4 -0
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +5 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +53 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js +4 -8
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +5 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +3 -7
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +18 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +167 -0
- package/build/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build/components/use-display-block-controls/index.native.js.map +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.native.js +95 -0
- package/build/components/use-on-block-drop/index.native.js.map +1 -0
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +12 -12
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-input.js +15 -0
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/elements/index.js +9 -0
- package/build/elements/index.js.map +1 -0
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -7
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +14 -7
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color-panel.native.js.map +1 -1
- package/build/hooks/color.js +8 -88
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +14 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +38 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +14 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +6 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +14 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +17 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +30 -2
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js.map +1 -1
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/autocompleters/block.js +4 -1
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +3 -11
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +3 -78
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-context/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +453 -0
- package/build-module/components/block-draggable/index.native.js.map +1 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build-module/components/block-list/block-list-context.native.js +179 -0
- package/build-module/components/block-list/block-list-context.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item.native.js +12 -9
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +26 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +35 -33
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +72 -23
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -5
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +18 -5
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -1
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +19 -8
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +5 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +1 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +3 -5
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +9 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +5 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +3 -5
- package/build-module/components/block-styles/menu-items.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/utils.js +3 -5
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -0
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +2 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +13 -2
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +11 -4
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +124 -43
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/copy-handler/index.js +18 -2
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.native.js.map +1 -1
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +52 -51
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +4 -1
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +4 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -1
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -5
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/no-results.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +2 -2
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +46 -0
- package/build-module/components/inspector-popover-header/index.js.map +1 -0
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/constants.js +5 -0
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/index.js +2 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +1 -2
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-input.js +3 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -4
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +2 -5
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +5 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +0 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +1 -6
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -3
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +22 -9
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +8 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +63 -8
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +4 -0
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +4 -1
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +40 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js +3 -5
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +5 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -5
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +15 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +148 -0
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build-module/components/use-display-block-controls/index.native.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.native.js +83 -0
- package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +12 -11
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +15 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/elements/index.js +2 -0
- package/build-module/elements/index.js.map +1 -0
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -7
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +11 -6
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color-panel.native.js.map +1 -1
- package/build-module/hooks/color.js +8 -88
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +14 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +39 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +15 -14
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +6 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +12 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +25 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/style-rtl.css +79 -197
- package/build-style/style.css +79 -197
- package/package.json +30 -30
- package/src/autocompleters/block.js +2 -1
- package/src/components/block-actions/index.js +2 -3
- package/src/components/block-alignment-control/ui.js +4 -6
- package/src/components/block-alignment-matrix-control/index.js +3 -9
- package/src/components/block-breadcrumb/index.js +2 -5
- package/src/components/block-compare/test/block-view.js +2 -1
- package/src/components/block-content-overlay/index.js +10 -100
- package/src/components/block-content-overlay/style.scss +2 -11
- package/src/components/block-context/index.js +4 -4
- package/src/components/block-controls/hook.js +2 -3
- package/src/components/block-draggable/draggable-chip.native.js +49 -0
- package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
- package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
- package/src/components/block-draggable/index.js +6 -13
- package/src/components/block-draggable/index.native.js +454 -0
- package/src/components/block-draggable/style.native.scss +19 -0
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
- package/src/components/block-draggable/test/helpers.native.js +183 -0
- package/src/components/block-draggable/test/index.native.js +493 -0
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
- package/src/components/block-edit/test/edit.js +2 -1
- package/src/components/block-list/block-list-context.native.js +175 -0
- package/src/components/block-list/block-list-item-cell.native.js +49 -0
- package/src/components/block-list/block-list-item.native.js +11 -23
- package/src/components/block-list/block-selection-button.native.js +2 -3
- package/src/components/block-list/block.js +8 -10
- package/src/components/block-list/block.native.js +47 -23
- package/src/components/block-list/index.js +46 -47
- package/src/components/block-list/index.native.js +63 -31
- package/src/components/block-list/test/block-list-context.native.js +245 -0
- package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
- package/src/components/block-list/use-block-props/index.js +16 -8
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +2 -3
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -3
- package/src/components/block-list/use-in-between-inserter.js +3 -4
- package/src/components/block-list-appender/index.js +2 -5
- package/src/components/block-list-appender/index.native.js +2 -3
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
- package/src/components/block-mobile-toolbar/index.native.js +9 -1
- package/src/components/block-mover/button.js +2 -3
- package/src/components/block-mover/index.native.js +26 -12
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
- package/src/components/block-parent-selector/index.js +2 -3
- package/src/components/block-pattern-setup/index.js +3 -5
- package/src/components/block-popover/inbetween.js +21 -8
- package/src/components/block-popover/index.js +2 -16
- package/src/components/block-popover/style.scss +1 -0
- package/src/components/block-preview/auto.js +4 -8
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-selection-clearer/index.js +2 -3
- package/src/components/block-settings-menu/block-mode-toggle.js +4 -8
- package/src/components/block-settings-menu/block-settings-dropdown.js +9 -9
- package/src/components/block-styles/index.js +3 -1
- package/src/components/block-styles/menu-items.js +2 -5
- package/src/components/block-switcher/block-transformations-menu.js +2 -4
- package/src/components/block-switcher/style.scss +2 -39
- package/src/components/block-toolbar/index.native.js +2 -5
- package/src/components/block-toolbar/utils.js +3 -11
- package/src/components/block-tools/block-contextual-toolbar.js +2 -5
- package/src/components/block-tools/block-selection-button.js +1 -0
- package/src/components/block-tools/index.js +2 -3
- package/src/components/block-tools/selected-block-popover.js +1 -36
- package/src/components/block-tools/style.scss +1 -12
- package/src/components/block-types-list/index.native.js +2 -4
- package/src/components/block-variation-transforms/index.js +10 -8
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +3 -2
- package/src/components/color-palette/test/control.js +2 -1
- package/src/components/color-style-selector/index.js +27 -28
- package/src/components/colors/test/with-colors.js +14 -14
- package/src/components/colors/with-colors.js +8 -12
- package/src/components/colors-gradients/dropdown.js +135 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
- package/src/components/colors-gradients/style.scss +52 -50
- package/src/components/colors-gradients/test/control.js +10 -10
- package/src/components/convert-to-group-buttons/toolbar.js +32 -19
- package/src/components/copy-handler/README.md +7 -2
- package/src/components/copy-handler/index.js +26 -6
- package/src/components/default-block-appender/index.js +4 -6
- package/src/components/default-block-appender/index.native.js +4 -9
- package/src/components/default-style-picker/index.js +20 -21
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/font-sizes/with-font-sizes.js +2 -3
- package/src/components/iframe/index.js +62 -54
- package/src/components/image-editor/aspect-ratio-dropdown.js +2 -6
- package/src/components/image-editor/use-save-image.js +2 -1
- package/src/components/image-size-control/index.js +4 -7
- package/src/components/index.js +4 -2
- package/src/components/inner-blocks/use-inner-block-template-sync.js +2 -3
- package/src/components/inner-blocks/use-nested-settings-update.js +6 -9
- package/src/components/inserter/block-types-tab.native.js +2 -3
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -3
- package/src/components/inserter/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/hooks/use-patterns-state.js +4 -5
- package/src/components/inserter/index.js +4 -6
- package/src/components/inserter/index.native.js +7 -12
- package/src/components/inserter/library.js +2 -5
- package/src/components/inserter/menu.js +14 -19
- package/src/components/inserter/menu.native.js +8 -6
- package/src/components/inserter/no-results.native.js +2 -1
- package/src/components/inserter/quick-inserter.js +2 -3
- package/src/components/inserter/search-items.js +6 -6
- package/src/components/inserter/search-results.native.js +4 -6
- package/src/components/inserter/style.scss +2 -1
- package/src/components/inspector-popover-header/README.md +76 -0
- package/src/components/inspector-popover-header/index.js +56 -0
- package/src/components/inspector-popover-header/style.scss +16 -0
- package/src/components/line-height-control/index.js +1 -2
- package/src/components/link-control/constants.js +11 -0
- package/src/components/link-control/index.js +4 -4
- package/src/components/link-control/search-create-button.js +4 -2
- package/src/components/link-control/search-input.js +3 -1
- package/src/components/link-control/search-results.js +4 -5
- package/src/components/link-control/settings-drawer.js +2 -5
- package/src/components/link-control/test/fixtures/index.js +3 -4
- package/src/components/link-control/test/index.js +24 -36
- package/src/components/link-control/use-search-handler.js +13 -7
- package/src/components/list-view/block-contents.js +2 -4
- package/src/components/list-view/branch.js +22 -23
- package/src/components/list-view/drop-indicator.js +0 -1
- package/src/components/list-view/index.js +4 -8
- package/src/components/list-view/style.scss +2 -1
- package/src/components/list-view/use-block-selection.js +5 -5
- package/src/components/list-view/use-list-view-drop-zone.js +2 -1
- package/src/components/list-view/utils.js +1 -6
- package/src/components/media-placeholder/index.js +2 -3
- package/src/components/media-replace-flow/index.js +77 -48
- package/src/components/media-upload/index.native.js +6 -2
- package/src/components/media-upload/test/index.native.js +31 -6
- package/src/components/navigable-toolbar/index.js +13 -4
- package/src/components/panel-color-settings/test/index.js +2 -1
- package/src/components/plain-text/index.native.js +60 -8
- package/src/components/preview-options/index.js +4 -0
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/provider/use-block-sync.js +5 -2
- package/src/components/publish-date-time-picker/README.md +52 -0
- package/src/components/publish-date-time-picker/index.js +39 -0
- package/src/components/responsive-block-control/test/index.js +3 -2
- package/src/components/rich-text/embed-handler-picker.native.js +2 -5
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +10 -5
- package/src/components/rich-text/index.native.js +4 -0
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/rich-text/use-format-types.js +16 -16
- package/src/components/rich-text/use-mark-persistent.js +2 -3
- package/src/components/skip-to-selected-block/index.js +2 -3
- package/src/components/ungroup-button/index.native.js +4 -8
- package/src/components/url-input/index.js +24 -21
- package/src/components/use-block-display-information/index.js +4 -6
- package/src/components/use-block-drop-zone/index.js +2 -3
- package/src/components/use-block-drop-zone/index.native.js +171 -0
- package/src/components/use-block-drop-zone/test/index.js +22 -23
- package/src/components/use-display-block-controls/index.native.js +2 -3
- package/src/components/use-no-recursive-renders/test/use-no-recursive-renders.js +2 -3
- package/src/components/use-on-block-drop/index.js +2 -5
- package/src/components/use-on-block-drop/index.native.js +115 -0
- package/src/components/use-setting/index.js +8 -6
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/components/writing-flow/test/index.js +22 -4
- package/src/components/writing-flow/use-arrow-nav.js +22 -10
- package/src/components/writing-flow/use-click-selection.js +2 -5
- package/src/components/writing-flow/use-drag-selection.js +6 -9
- package/src/components/writing-flow/use-input.js +12 -0
- package/src/components/writing-flow/use-multi-selection.js +2 -4
- package/src/components/writing-flow/use-select-all.js +2 -5
- package/src/components/writing-flow/use-selection-observer.js +4 -6
- package/src/components/writing-flow/use-tab-nav.js +2 -5
- package/src/elements/index.js +1 -0
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +2 -11
- package/src/hooks/border.scss +0 -48
- package/src/hooks/color-panel.js +17 -13
- package/src/hooks/color-panel.native.js +2 -2
- package/src/hooks/color.js +7 -76
- package/src/hooks/color.scss +5 -58
- package/src/hooks/dimensions.js +11 -3
- package/src/hooks/font-family.js +4 -2
- package/src/hooks/gap.js +2 -3
- package/src/hooks/layout.js +54 -4
- package/src/hooks/style.js +25 -39
- package/src/hooks/test/align.js +2 -1
- package/src/hooks/test/generated-class-name.js +2 -5
- package/src/hooks/test/utils.js +2 -5
- package/src/hooks/typography.js +2 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +11 -3
- package/src/store/actions.js +784 -728
- package/src/store/reducer.js +202 -178
- package/src/store/selectors.js +82 -54
- package/src/store/test/actions.js +2 -1
- package/src/store/test/reducer.js +8 -1
- package/src/store/test/selectors.js +17 -21
- package/src/style.scss +1 -1
- package/src/utils/pasting.js +3 -3
- package/src/utils/transform-styles/transforms/wrap.js +30 -28
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/colors/color-panel.js +0 -82
- package/build/components/colors/color-panel.js.map +0 -1
- package/build/components/colors/color-panel.native.js +0 -11
- package/build/components/colors/color-panel.native.js.map +0 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/colors/color-panel.js +0 -70
- package/build-module/components/colors/color-panel.js.map +0 -1
- package/build-module/components/colors/color-panel.native.js +0 -4
- package/build-module/components/colors/color-panel.native.js.map +0 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/colors/color-panel.js +0 -91
- package/src/components/colors/color-panel.native.js +0 -3
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
|
@@ -10,7 +10,7 @@ import { TextInput, Platform, Dimensions } from 'react-native';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
|
-
import { getPxFromCssUnit } from '@wordpress/block-editor';
|
|
13
|
+
import { RichText, getPxFromCssUnit } from '@wordpress/block-editor';
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
@@ -20,6 +20,8 @@ export default class PlainText extends Component {
|
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
22
|
this.isAndroid = Platform.OS === 'android';
|
|
23
|
+
this.onChangeTextInput = this.onChangeTextInput.bind(this);
|
|
24
|
+
this.onChangeRichText = this.onChangeRichText.bind(this);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
componentDidMount() {
|
|
@@ -42,7 +44,9 @@ export default class PlainText extends Component {
|
|
|
42
44
|
|
|
43
45
|
componentDidUpdate(prevProps) {
|
|
44
46
|
if (!this.props.isSelected && prevProps.isSelected) {
|
|
45
|
-
|
|
47
|
+
var _this$_input;
|
|
48
|
+
|
|
49
|
+
(_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.blur();
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
|
|
@@ -53,11 +57,15 @@ export default class PlainText extends Component {
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
focus() {
|
|
56
|
-
|
|
60
|
+
var _this$_input2;
|
|
61
|
+
|
|
62
|
+
(_this$_input2 = this._input) === null || _this$_input2 === void 0 ? void 0 : _this$_input2.focus();
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
blur() {
|
|
60
|
-
|
|
66
|
+
var _this$_input3;
|
|
67
|
+
|
|
68
|
+
(_this$_input3 = this._input) === null || _this$_input3 === void 0 ? void 0 : _this$_input3.blur();
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
getFontSize() {
|
|
@@ -82,16 +90,63 @@ export default class PlainText extends Component {
|
|
|
82
90
|
};
|
|
83
91
|
}
|
|
84
92
|
|
|
93
|
+
replaceLineBreakTags(value) {
|
|
94
|
+
return value === null || value === void 0 ? void 0 : value.replace(RegExp('<br>', 'gim'), '\n');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
onChangeTextInput(event) {
|
|
98
|
+
const {
|
|
99
|
+
onChange
|
|
100
|
+
} = this.props;
|
|
101
|
+
onChange(event.nativeEvent.text);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
onChangeRichText(value) {
|
|
105
|
+
const {
|
|
106
|
+
onChange
|
|
107
|
+
} = this.props; // The <br> tags have to be replaced with new line characters
|
|
108
|
+
// as the content of plain text shouldn't contain HTML tags.
|
|
109
|
+
|
|
110
|
+
onChange(this.replaceLineBreakTags(value));
|
|
111
|
+
}
|
|
112
|
+
|
|
85
113
|
render() {
|
|
86
114
|
const {
|
|
87
|
-
style
|
|
115
|
+
style,
|
|
116
|
+
__experimentalVersion,
|
|
117
|
+
onFocus,
|
|
118
|
+
...otherProps
|
|
88
119
|
} = this.props;
|
|
89
120
|
const textStyles = [style || styles['block-editor-plain-text'], this.getFontSize()];
|
|
121
|
+
|
|
122
|
+
if (__experimentalVersion === 2) {
|
|
123
|
+
const disableFormattingProps = {
|
|
124
|
+
withoutInteractiveFormatting: true,
|
|
125
|
+
disableEditingMenu: true,
|
|
126
|
+
__unstableDisableFormats: true,
|
|
127
|
+
disableSuggestions: true
|
|
128
|
+
};
|
|
129
|
+
const forcePlainTextProps = {
|
|
130
|
+
preserveWhiteSpace: true,
|
|
131
|
+
__unstablePastePlainText: true,
|
|
132
|
+
multiline: false
|
|
133
|
+
};
|
|
134
|
+
const fontProps = {
|
|
135
|
+
fontFamily: style === null || style === void 0 ? void 0 : style.fontFamily,
|
|
136
|
+
fontSize: style === null || style === void 0 ? void 0 : style.fontSize,
|
|
137
|
+
fontWeight: style === null || style === void 0 ? void 0 : style.fontWeight
|
|
138
|
+
};
|
|
139
|
+
return createElement(RichText, _extends({}, otherProps, disableFormattingProps, forcePlainTextProps, fontProps, {
|
|
140
|
+
identifier: "content",
|
|
141
|
+
style: style,
|
|
142
|
+
onChange: this.onChangeRichText,
|
|
143
|
+
unstableOnFocus: onFocus
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
|
|
90
147
|
return createElement(TextInput, _extends({}, this.props, {
|
|
91
148
|
ref: x => this._input = x,
|
|
92
|
-
onChange:
|
|
93
|
-
this.props.onChange(event.nativeEvent.text);
|
|
94
|
-
},
|
|
149
|
+
onChange: this.onChangeTextInput,
|
|
95
150
|
onFocus: this.props.onFocus // Always assign onFocus as a props.
|
|
96
151
|
,
|
|
97
152
|
onBlur: this.props.onBlur // Always assign onBlur as a props.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.native.js"],"names":["TextInput","Platform","Dimensions","Component","getPxFromCssUnit","styles","PlainText","constructor","arguments","isAndroid","OS","componentDidMount","_input","isFocused","props","isSelected","timeoutID","setTimeout","focus","componentDidUpdate","prevProps","blur","componentWillUnmount","clearTimeout","getFontSize","style","fontSize","width","height","get","cssUnitOptions","parseFloat","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.native.js"],"names":["TextInput","Platform","Dimensions","Component","RichText","getPxFromCssUnit","styles","PlainText","constructor","arguments","isAndroid","OS","onChangeTextInput","bind","onChangeRichText","componentDidMount","_input","isFocused","props","isSelected","timeoutID","setTimeout","focus","componentDidUpdate","prevProps","blur","componentWillUnmount","clearTimeout","getFontSize","style","fontSize","width","height","get","cssUnitOptions","parseFloat","replaceLineBreakTags","value","replace","RegExp","event","onChange","nativeEvent","text","render","__experimentalVersion","onFocus","otherProps","textStyles","disableFormattingProps","withoutInteractiveFormatting","disableEditingMenu","__unstableDisableFormats","disableSuggestions","forcePlainTextProps","preserveWhiteSpace","__unstablePastePlainText","multiline","fontProps","fontFamily","fontWeight","x","onBlur"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,UAA9B,QAAgD,cAAhD;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,QAAT,EAAmBC,gBAAnB,QAA2C,yBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,eAAe,MAAMC,SAAN,SAAwBJ,SAAxB,CAAkC;AAChDK,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,SAAL,GAAiBT,QAAQ,CAACU,EAAT,KAAgB,SAAjC;AAEA,SAAKC,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBC,IAAvB,CAA6B,IAA7B,CAAzB;AACA,SAAKC,gBAAL,GAAwB,KAAKA,gBAAL,CAAsBD,IAAtB,CAA4B,IAA5B,CAAxB;AACA;;AAEDE,EAAAA,iBAAiB,GAAG;AACnB;AACA,QACC,KAAKC,MAAL,IACA,KAAKA,MAAL,CAAYC,SAAZ,OAA4B,KAD5B,IAEA,KAAKC,KAAL,CAAWC,UAHZ,EAIE;AACD,UAAK,KAAKT,SAAV,EAAsB;AACrB;AACJ;AACA;AACA;AACA;AACI,aAAKU,SAAL,GAAiBC,UAAU,CAAE,MAAM;AAClC,eAAKL,MAAL,CAAYM,KAA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,EAEME,sBAFN,EAGMK,mBAHN,EAIMI,SAJN;AAKC,QAAA,UAAU,EAAC,SALZ;AAMC,QAAA,KAAK,EAAG7B,KANT;AAOC,QAAA,QAAQ,EAAG,KAAKf,gBAPjB;AAQC,QAAA,eAAe,EAAGgC;AARnB,SADD;AAYA;;AAED,WACC,cAAC,SAAD,eACM,KAAK5B,KADX;AAEC,MAAA,GAAG,EAAK2C,CAAF,IAAW,KAAK7C,MAAL,GAAc6C,CAFhC;AAGC,MAAA,QAAQ,EAAG,KAAKjD,iBAHjB;AAIC,MAAA,OAAO,EAAG,KAAKM,KAAL,CAAW4B,OAJtB,CAIgC;AAJhC;AAKC,MAAA,MAAM,EAAG,KAAK5B,KAAL,CAAW4C,MALrB,CAK8B;AAL9B;AAMC,MAAA,UAAU,EACP,KAAK5C,KAAL,CAAWW,KAAX,IAAoB,KAAKX,KAAL,CAAWW,KAAX,CAAiB8B,UAAvC,IACArD,MAAM,CAAE,yBAAF,CAAN,CAAoCqD,UARtC;AAUC,MAAA,KAAK,EAAGX,UAVT;AAWC,MAAA,aAAa,EAAG;AAXjB,OADD;AAeA;;AA7I+C","sourcesContent":["/**\n * External dependencies\n */\nimport { TextInput, Platform, Dimensions } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { RichText, getPxFromCssUnit } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport default class PlainText extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.isAndroid = Platform.OS === 'android';\n\n\t\tthis.onChangeTextInput = this.onChangeTextInput.bind( this );\n\t\tthis.onChangeRichText = this.onChangeRichText.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\t// If isSelected is true, we should request the focus on this TextInput.\n\t\tif (\n\t\t\tthis._input &&\n\t\t\tthis._input.isFocused() === false &&\n\t\t\tthis.props.isSelected\n\t\t) {\n\t\t\tif ( this.isAndroid ) {\n\t\t\t\t/*\n\t\t\t\t * There seems to be an issue in React Native where the keyboard doesn't show if called shortly after rendering.\n\t\t\t\t * As a common work around this delay is used.\n\t\t\t\t * https://github.com/facebook/react-native/issues/19366#issuecomment-400603928\n\t\t\t\t */\n\t\t\t\tthis.timeoutID = setTimeout( () => {\n\t\t\t\t\tthis._input.focus();\n\t\t\t\t}, 100 );\n\t\t\t} else {\n\t\t\t\tthis._input.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! this.props.isSelected && prevProps.isSelected ) {\n\t\t\tthis._input?.blur();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.isAndroid ) {\n\t\t\tclearTimeout( this.timeoutID );\n\t\t}\n\t}\n\n\tfocus() {\n\t\tthis._input?.focus();\n\t}\n\n\tblur() {\n\t\tthis._input?.blur();\n\t}\n\n\tgetFontSize() {\n\t\tconst { style } = this.props;\n\n\t\tif ( ! style?.fontSize ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { width, height } = Dimensions.get( 'window' );\n\t\tconst cssUnitOptions = { height, width };\n\n\t\treturn {\n\t\t\tfontSize: parseFloat(\n\t\t\t\tgetPxFromCssUnit( style.fontSize, cssUnitOptions )\n\t\t\t),\n\t\t};\n\t}\n\n\treplaceLineBreakTags( value ) {\n\t\treturn value?.replace( RegExp( '<br>', 'gim' ), '\\n' );\n\t}\n\n\tonChangeTextInput( event ) {\n\t\tconst { onChange } = this.props;\n\t\tonChange( event.nativeEvent.text );\n\t}\n\n\tonChangeRichText( value ) {\n\t\tconst { onChange } = this.props;\n\t\t// The <br> tags have to be replaced with new line characters\n\t\t// as the content of plain text shouldn't contain HTML tags.\n\t\tonChange( this.replaceLineBreakTags( value ) );\n\t}\n\n\trender() {\n\t\tconst { style, __experimentalVersion, onFocus, ...otherProps } =\n\t\t\tthis.props;\n\t\tconst textStyles = [\n\t\t\tstyle || styles[ 'block-editor-plain-text' ],\n\t\t\tthis.getFontSize(),\n\t\t];\n\n\t\tif ( __experimentalVersion === 2 ) {\n\t\t\tconst disableFormattingProps = {\n\t\t\t\twithoutInteractiveFormatting: true,\n\t\t\t\tdisableEditingMenu: true,\n\t\t\t\t__unstableDisableFormats: true,\n\t\t\t\tdisableSuggestions: true,\n\t\t\t};\n\n\t\t\tconst forcePlainTextProps = {\n\t\t\t\tpreserveWhiteSpace: true,\n\t\t\t\t__unstablePastePlainText: true,\n\t\t\t\tmultiline: false,\n\t\t\t};\n\n\t\t\tconst fontProps = {\n\t\t\t\tfontFamily: style?.fontFamily,\n\t\t\t\tfontSize: style?.fontSize,\n\t\t\t\tfontWeight: style?.fontWeight,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText\n\t\t\t\t\t{ ...otherProps }\n\t\t\t\t\t{ ...disableFormattingProps }\n\t\t\t\t\t{ ...forcePlainTextProps }\n\t\t\t\t\t{ ...fontProps }\n\t\t\t\t\tidentifier=\"content\"\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tonChange={ this.onChangeRichText }\n\t\t\t\t\tunstableOnFocus={ onFocus }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TextInput\n\t\t\t\t{ ...this.props }\n\t\t\t\tref={ ( x ) => ( this._input = x ) }\n\t\t\t\tonChange={ this.onChangeTextInput }\n\t\t\t\tonFocus={ this.props.onFocus } // Always assign onFocus as a props.\n\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\tfontFamily={\n\t\t\t\t\t( this.props.style && this.props.style.fontFamily ) ||\n\t\t\t\t\tstyles[ 'block-editor-plain-text' ].fontFamily\n\t\t\t\t}\n\t\t\t\tstyle={ textStyles }\n\t\t\t\tscrollEnabled={ false }\n\t\t\t/>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -34,10 +34,14 @@ export default function PreviewOptions(_ref) {
|
|
|
34
34
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
35
35
|
children: __('Preview')
|
|
36
36
|
};
|
|
37
|
+
const menuProps = {
|
|
38
|
+
'aria-label': __('Preview options')
|
|
39
|
+
};
|
|
37
40
|
return createElement(DropdownMenu, {
|
|
38
41
|
className: "block-editor-post-preview__dropdown",
|
|
39
42
|
popoverProps: popoverProps,
|
|
40
43
|
toggleProps: toggleProps,
|
|
44
|
+
menuProps: menuProps,
|
|
41
45
|
icon: null
|
|
42
46
|
}, () => createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
|
|
43
47
|
className: "block-editor-post-preview__button-resize",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"names":["classnames","useViewportMatch","DropdownMenu","MenuGroup","MenuItem","__","check","PreviewOptions","children","className","isEnabled","deviceType","setDeviceType","isMobile","popoverProps","position","toggleProps","variant","disabled"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA,eAAe,SAASC,cAAT,OAMX;AAAA,MANoC;AACvCC,IAAAA,QADuC;AAEvCC,IAAAA,SAFuC;AAGvCC,IAAAA,SAAS,GAAG,IAH2B;AAIvCC,IAAAA,UAJuC;AAKvCC,IAAAA;AALuC,GAMpC;AACH,QAAMC,QAAQ,GAAGZ,gBAAgB,CAAE,OAAF,EAAW,GAAX,CAAjC;AACA,MAAKY,QAAL,EAAgB,OAAO,IAAP;AAEhB,QAAMC,YAAY,GAAG;AACpBL,IAAAA,SAAS,EAAET,UAAU,CACpBS,SADoB,EAEpB,6CAFoB,CADD;AAKpBM,IAAAA,QAAQ,EAAE;AALU,GAArB;AAOA,QAAMC,WAAW,GAAG;AACnBC,IAAAA,OAAO,EAAE,UADU;AAEnBR,IAAAA,SAAS,EAAE,0CAFQ;AAGnBS,IAAAA,QAAQ,EAAE,CAAER,SAHO;;AAInB;AACAF,IAAAA,QAAQ,EAAEH,EAAE,CAAE,SAAF;AALO,GAApB;AAOA,SACC,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,YAAY,EAAGS,YAFhB;AAGC,IAAA,WAAW,EAAGE,WAHf;AAIC,IAAA,IAAI,EAAG;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"names":["classnames","useViewportMatch","DropdownMenu","MenuGroup","MenuItem","__","check","PreviewOptions","children","className","isEnabled","deviceType","setDeviceType","isMobile","popoverProps","position","toggleProps","variant","disabled","menuProps"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA,eAAe,SAASC,cAAT,OAMX;AAAA,MANoC;AACvCC,IAAAA,QADuC;AAEvCC,IAAAA,SAFuC;AAGvCC,IAAAA,SAAS,GAAG,IAH2B;AAIvCC,IAAAA,UAJuC;AAKvCC,IAAAA;AALuC,GAMpC;AACH,QAAMC,QAAQ,GAAGZ,gBAAgB,CAAE,OAAF,EAAW,GAAX,CAAjC;AACA,MAAKY,QAAL,EAAgB,OAAO,IAAP;AAEhB,QAAMC,YAAY,GAAG;AACpBL,IAAAA,SAAS,EAAET,UAAU,CACpBS,SADoB,EAEpB,6CAFoB,CADD;AAKpBM,IAAAA,QAAQ,EAAE;AALU,GAArB;AAOA,QAAMC,WAAW,GAAG;AACnBC,IAAAA,OAAO,EAAE,UADU;AAEnBR,IAAAA,SAAS,EAAE,0CAFQ;AAGnBS,IAAAA,QAAQ,EAAE,CAAER,SAHO;;AAInB;AACAF,IAAAA,QAAQ,EAAEH,EAAE,CAAE,SAAF;AALO,GAApB;AAOA,QAAMc,SAAS,GAAG;AACjB,kBAAcd,EAAE,CAAE,iBAAF;AADC,GAAlB;AAGA,SACC,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,YAAY,EAAGS,YAFhB;AAGC,IAAA,WAAW,EAAGE,WAHf;AAIC,IAAA,SAAS,EAAGG,SAJb;AAKC,IAAA,IAAI,EAAG;AALR,KAOG,MACD,8BACC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,OAAO,EAAG,MAAMP,aAAa,CAAE,SAAF,CAF9B;AAGC,IAAA,IAAI,EAAGD,UAAU,KAAK,SAAf,IAA4BL;AAHpC,KAKGD,EAAE,CAAE,SAAF,CALL,CADD,EAQC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,OAAO,EAAG,MAAMO,aAAa,CAAE,QAAF,CAF9B;AAGC,IAAA,IAAI,EAAGD,UAAU,KAAK,QAAf,IAA2BL;AAHnC,KAKGD,EAAE,CAAE,QAAF,CALL,CARD,EAeC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,OAAO,EAAG,MAAMO,aAAa,CAAE,QAAF,CAF9B;AAGC,IAAA,IAAI,EAAGD,UAAU,KAAK,QAAf,IAA2BL;AAHnC,KAKGD,EAAE,CAAE,QAAF,CALL,CAfD,CADD,EAwBGG,QAxBH,CARF,CADD;AAsCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nexport default function PreviewOptions( {\n\tchildren,\n\tclassName,\n\tisEnabled = true,\n\tdeviceType,\n\tsetDeviceType,\n} ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tclassName: classnames(\n\t\t\tclassName,\n\t\t\t'block-editor-post-preview__dropdown-content'\n\t\t),\n\t\tposition: 'bottom left',\n\t};\n\tconst toggleProps = {\n\t\tvariant: 'tertiary',\n\t\tclassName: 'block-editor-post-preview__button-toggle',\n\t\tdisabled: ! isEnabled,\n\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\tchildren: __( 'Preview' ),\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'Preview options' ),\n\t};\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-post-preview__dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ children }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { last
|
|
4
|
+
import { last } from 'lodash';
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
@@ -14,6 +14,8 @@ import { cloneBlock } from '@wordpress/blocks';
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { store as blockEditorStore } from '../../store';
|
|
17
|
+
|
|
18
|
+
const noop = () => {};
|
|
17
19
|
/**
|
|
18
20
|
* A function to call when the block value has been updated in the block-editor
|
|
19
21
|
* store.
|
|
@@ -66,6 +68,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
66
68
|
* controlling sources do not become dirty.
|
|
67
69
|
*/
|
|
68
70
|
|
|
71
|
+
|
|
69
72
|
export default function useBlockSync(_ref) {
|
|
70
73
|
let {
|
|
71
74
|
clientId = null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["last","noop","useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","getBlockName","getBlocks","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","selectionStart","selectionEnd","initialPosition","getSelectionStart","getSelectionEnd","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,IAAf,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,QAAQ,GAAG,IAD0B;AAErCC,IAAAA,KAAK,EAAEC,gBAF8B;AAGrCC,IAAAA,SAAS,EAAEC,mBAH0B;AAIrCC,IAAAA,QAAQ,GAAGd,IAJ0B;AAKrCe,IAAAA,OAAO,GAAGf;AAL2B,GAMlC;AACH,QAAMgB,QAAQ,GAAGb,WAAW,EAA5B;AAEA,QAAM;AACLc,IAAAA,WADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,kBAHK;AAILC,IAAAA,2BAJK;AAKLC,IAAAA;AALK,MAMFL,QAAQ,CAACM,QAAT,CAAmBf,gBAAnB,CANJ;AAOA,QAAM;AAAEgB,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA8BR,QAAQ,CAACS,MAAT,CAAiBlB,gBAAjB,CAApC;AACA,QAAMmB,YAAY,GAAGtB,SAAS,CAC3BqB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,CAEjD;AACA;AACA;AACA;;AACA3B,QAAAA,cAAc,CAACS,OAAf,CAAuBP,QAAvB,CAAgC6B,IAAhC,CAAsCV,MAAtC,EANiD,CAQjD;AACA;;AACA,cAAMW,YAAY,GAAGV,YAAY,GAC9BX,WAAW,CAACF,OADkB,GAE9BC,UAAU,CAACD,OAFd;AAGAuB,QAAAA,YAAY,CAAEX,MAAF,EAAU;AACrBrC,UAAAA,SAAS,EAAE;AACV6B,YAAAA,cAAc,EAAEG,iBAAiB,EADvB;AAEVF,YAAAA,YAAY,EAAEG,eAAe,EAFnB;AAGVF,YAAAA,eAAe,EAAEG,qCAAqC;AAH5C;AADU,SAAV,CAAZ;AAOA;;AACDK,MAAAA,0BAA0B,GAAGM,kBAA7B;AACA,KAnEmB,CAApB;AAqEA,WAAO,MAAML,WAAW,EAAxB;AACA,GArFQ,EAqFN,CAAEpC,QAAF,EAAYP,QAAZ,CArFM,CAAT;AAsFA","sourcesContent":["/**\n * External dependencies\n */\nimport { last, noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks } = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tlast( pendingChanges.current.outgoing ) === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition: getSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t} );\n\n\t\treturn () => unsubscribe();\n\t}, [ registry, clientId ] );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["last","useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","getBlockName","getBlocks","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","selectionStart","selectionEnd","initialPosition","getSelectionStart","getSelectionEnd","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAF,EAAYP,QAAZ,CAtFM,CAAT;AAuFA","sourcesContent":["/**\n * External dependencies\n */\nimport { last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks } = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tlast( pendingChanges.current.outgoing ) === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t} );\n\n\t\treturn () => unsubscribe();\n\t}, [ registry, clientId ] );\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WordPress dependencies
|
|
6
|
+
*/
|
|
7
|
+
import { DateTimePicker } from '@wordpress/components';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import InspectorPopoverHeader from '../inspector-popover-header';
|
|
15
|
+
|
|
16
|
+
function PublishDateTimePicker(_ref, ref) {
|
|
17
|
+
let {
|
|
18
|
+
onClose,
|
|
19
|
+
onChange,
|
|
20
|
+
...additionalProps
|
|
21
|
+
} = _ref;
|
|
22
|
+
return createElement("div", {
|
|
23
|
+
ref: ref,
|
|
24
|
+
className: "block-editor-publish-date-time-picker"
|
|
25
|
+
}, createElement(InspectorPopoverHeader, {
|
|
26
|
+
title: __('Publish'),
|
|
27
|
+
actions: [{
|
|
28
|
+
label: __('Now'),
|
|
29
|
+
onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(null)
|
|
30
|
+
}],
|
|
31
|
+
onClose: onClose
|
|
32
|
+
}), createElement(DateTimePicker, _extends({
|
|
33
|
+
__nextRemoveHelpButton: true,
|
|
34
|
+
__nextRemoveResetButton: true,
|
|
35
|
+
onChange: onChange
|
|
36
|
+
}, additionalProps)));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default forwardRef(PublishDateTimePicker);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/publish-date-time-picker/index.js"],"names":["DateTimePicker","__","forwardRef","InspectorPopoverHeader","PublishDateTimePicker","ref","onClose","onChange","additionalProps","label","onClick"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;;AAEA,SAASC,qBAAT,OAECC,GAFD,EAGE;AAAA,MAFD;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqB,OAAGC;AAAxB,GAEC;AACD,SACC;AAAK,IAAA,GAAG,EAAGH,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC,cAAC,sBAAD;AACC,IAAA,KAAK,EAAGJ,EAAE,CAAE,SAAF,CADX;AAEC,IAAA,OAAO,EAAG,CACT;AACCQ,MAAAA,KAAK,EAAER,EAAE,CAAE,KAAF,CADV;AAECS,MAAAA,OAAO,EAAE,MAAMH,QAAN,aAAMA,QAAN,uBAAMA,QAAQ,CAAI,IAAJ;AAFxB,KADS,CAFX;AAQC,IAAA,OAAO,EAAGD;AARX,IADD,EAWC,cAAC,cAAD;AACC,IAAA,sBAAsB,MADvB;AAEC,IAAA,uBAAuB,MAFxB;AAGC,IAAA,QAAQ,EAAGC;AAHZ,KAIMC,eAJN,EAXD,CADD;AAoBA;;AAED,eAAeN,UAAU,CAAEE,qBAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DateTimePicker } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorPopoverHeader from '../inspector-popover-header';\n\nfunction PublishDateTimePicker(\n\t{ onClose, onChange, ...additionalProps },\n\tref\n) {\n\treturn (\n\t\t<div ref={ ref } className=\"block-editor-publish-date-time-picker\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Publish' ) }\n\t\t\t\tactions={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Now' ),\n\t\t\t\t\t\tonClick: () => onChange?.( null ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<DateTimePicker\n\t\t\t\t__nextRemoveHelpButton\n\t\t\t\t__nextRemoveResetButton\n\t\t\t\tonChange={ onChange }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( PublishDateTimePicker );\n"]}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { noop } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { forwardRef, useRef, useImperativeHandle, memo, useCallback } from '@wordpress/element';
|
|
12
7
|
import { Picker } from '@wordpress/components';
|
|
13
8
|
import { __ } from '@wordpress/i18n';
|
|
9
|
+
|
|
10
|
+
const noop = () => {};
|
|
11
|
+
|
|
14
12
|
const DEFAULT_PICKER_OPTIONS = [{
|
|
15
13
|
id: 'createEmbed',
|
|
16
14
|
label: __('Create embed'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/embed-handler-picker.native.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/embed-handler-picker.native.js"],"names":["forwardRef","useRef","useImperativeHandle","memo","useCallback","Picker","__","noop","DEFAULT_PICKER_OPTIONS","id","label","value","onSelect","EmbedHandlerPicker","ref","pickerRef","pickerOptions","current","onPickerSelect","selectedItem","find","item","presentPicker","createEmbed","createLink"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,MAFD,EAGCC,mBAHD,EAICC,IAJD,EAKCC,WALD,QAMO,oBANP;AAOA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,sBAAsB,GAAG,CAC9B;AACCC,EAAAA,EAAE,EAAE,aADL;AAECC,EAAAA,KAAK,EAAEJ,EAAE,CAAE,cAAF,CAFV;AAGCK,EAAAA,KAAK,EAAE,aAHR;AAICC,EAAAA,QAAQ,EAAEL;AAJX,CAD8B,EAO9B;AACCE,EAAAA,EAAE,EAAE,YADL;AAECC,EAAAA,KAAK,EAAEJ,EAAE,CAAE,a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n\tuseCallback,\n} from '@wordpress/element';\nimport { Picker } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst noop = () => {};\n\nconst DEFAULT_PICKER_OPTIONS = [\n\t{\n\t\tid: 'createEmbed',\n\t\tlabel: __( 'Create embed' ),\n\t\tvalue: 'createEmbed',\n\t\tonSelect: noop,\n\t},\n\t{\n\t\tid: 'createLink',\n\t\tlabel: __( 'Create link' ),\n\t\tvalue: 'createLink',\n\t\tonSelect: noop,\n\t},\n];\n\nconst EmbedHandlerPicker = forwardRef( ( {}, ref ) => {\n\tconst pickerRef = useRef();\n\tconst pickerOptions = useRef( DEFAULT_PICKER_OPTIONS ).current;\n\n\tconst onPickerSelect = useCallback(\n\t\t( value ) => {\n\t\t\tconst selectedItem = pickerOptions.find(\n\t\t\t\t( item ) => item.value === value\n\t\t\t);\n\t\t\tselectedItem.onSelect();\n\t\t},\n\t\t[ pickerOptions ]\n\t);\n\n\tuseImperativeHandle( ref, () => ( {\n\t\tpresentPicker: ( { createEmbed, createLink } ) => {\n\t\t\tpickerOptions[ 0 ].onSelect = createEmbed;\n\t\t\tpickerOptions[ 1 ].onSelect = createLink;\n\t\t\tpickerRef.current?.presentPicker();\n\t\t},\n\t} ) );\n\n\treturn (\n\t\t<Picker\n\t\t\tref={ pickerRef }\n\t\t\toptions={ pickerOptions }\n\t\t\tonChange={ onPickerSelect }\n\t\t\ttestID=\"embed-handler-picker\"\n\t\t\thideCancelButton\n\t\t\tleftAlign\n\t\t/>\n\t);\n} );\n\nexport default memo( EmbedHandlerPicker );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-toolbar-container.js"],"names":["Popover","ToolbarGroup","BlockControls","FormatToolbar","FormatToolbarContainer","inline","anchorRef"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,YAAlB,QAAsC,uBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;;AAEA,MAAMC,sBAAsB,GAAG,QAA6B;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA2B;;AAC3D,MAAKD,MAAL,EAAc;AACb;AACA,WACC,cAAC,OAAD;AACC,MAAA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-toolbar-container.js"],"names":["Popover","ToolbarGroup","BlockControls","FormatToolbar","FormatToolbarContainer","inline","anchorRef"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,YAAlB,QAAsC,uBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;;AAEA,MAAMC,sBAAsB,GAAG,QAA6B;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA2B;;AAC3D,MAAKD,MAAL,EAAc;AACb;AACA,WACC,cAAC,OAAD;AACC,MAAA,QAAQ,EAAC,YADV;AAEC,MAAA,YAAY,EAAG,KAFhB;AAGC,MAAA,SAAS,EAAGC,SAHb;AAIC,MAAA,SAAS,EAAC,+CAJX;AAKC,MAAA,kBAAkB,EAAC;AALpB,OAOC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,YAAD,QACC,cAAC,aAAD,OADD,CADD,CAPD,CADD;AAeA,GAlB0D,CAmB3D;;;AACA,SACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,aAAD,OADD,CADD;AAKA,CAzBD;;AA2BA,eAAeF,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover, ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockControls from '../block-controls';\nimport FormatToolbar from './format-toolbar';\n\nconst FormatToolbarContainer = ( { inline, anchorRef } ) => {\n\tif ( inline ) {\n\t\t// Render in popover.\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\tposition=\"top center\"\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tanchorRef={ anchorRef }\n\t\t\t\tclassName=\"block-editor-rich-text__inline-format-toolbar\"\n\t\t\t\t__unstableSlotName=\"block-toolbar\"\n\t\t\t>\n\t\t\t\t<div className=\"block-editor-rich-text__inline-format-toolbar-group\">\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<FormatToolbar />\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n\t// Render regular toolbar.\n\treturn (\n\t\t<BlockControls group=\"inline\">\n\t\t\t<FormatToolbar />\n\t\t</BlockControls>\n\t);\n};\n\nexport default FormatToolbarContainer;\n"]}
|
|
@@ -50,7 +50,7 @@ export const inputEventContext = createContext();
|
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
52
|
function removeNativeProps(props) {
|
|
53
|
-
return omit(props, ['__unstableMobileNoFocusOnMount', 'deleteEnter', 'placeholderTextColor', 'textAlign', 'selectionColor', 'tagsToEliminate', 'rootTagsToEliminate', 'disableEditingMenu', 'fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'minWidth', 'maxWidth', 'setRef']);
|
|
53
|
+
return omit(props, ['__unstableMobileNoFocusOnMount', 'deleteEnter', 'placeholderTextColor', 'textAlign', 'selectionColor', 'tagsToEliminate', 'rootTagsToEliminate', 'disableEditingMenu', 'fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'minWidth', 'maxWidth', 'setRef', 'disableSuggestions', 'disableAutocorrection']);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function RichTextWrapper(_ref, forwardedRef) {
|
|
@@ -299,7 +299,7 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
299
299
|
forwardedRef: anchorRef
|
|
300
300
|
})))), isSelected && hasFormats && createElement(FormatToolbarContainer, {
|
|
301
301
|
inline: inlineToolbar,
|
|
302
|
-
anchorRef: anchorRef
|
|
302
|
+
anchorRef: anchorRef
|
|
303
303
|
}), createElement(TagName // Overridable props.
|
|
304
304
|
, _extends({
|
|
305
305
|
role: "textbox",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"names":["classnames","omit","RawHTML","useRef","useCallback","forwardRef","createContext","useDispatch","useSelect","children","childrenSource","useInstanceId","useMergeRefs","__unstableUseRichText","useRichText","__unstableCreateElement","isEmpty","isCollapsed","removeFormat","deprecated","BACKSPACE","DELETE","Popover","useBlockEditorAutocompleteProps","useBlockEditContext","FormatToolbarContainer","store","blockEditorStore","useUndoAutomaticChange","useMarkPersistent","usePasteHandler","useInputRules","useEnter","useFormatTypes","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useFirefoxCompat","FormatEdit","getMultilineTag","getAllowedFormats","keyboardShortcutContext","inputEventContext","removeNativeProps","props","RichTextWrapper","forwardedRef","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","formattingControls","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","unstableOnFocus","__unstableAllowPrefixTransformations","instanceId","anchorRef","clientId","selector","select","getSelectionStart","getSelectionEnd","selectionStart","selectionEnd","undefined","attributeKey","offset","selectionChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","name","addInvisibleFormats","ref","richTextRef","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableMultilineTag","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onKeyDown","event","keyCode","defaultPrevented","isReverse","hasActiveFormats","activeFormats","preventDefault","onFocus","current","focus","TagName","content","className","since","alternative","version","ForwardedRichTextContainer","Content","Tag","MultilineTag","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,OADD,EAECC,MAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,aALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,QAAQ,IAAIC,cAArB,QAA2C,mBAA3C;AACA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,oBAA5C;AACA,SACCC,qBAAqB,IAAIC,WAD1B,EAECC,uBAFD,EAGCC,OAHD,EAICC,WAJD,EAKCC,YALD,QAMO,sBANP;AAOA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,qBAAlC;AACA,SAASC,OAAT,QAAwB,uBAAxB;AAEA;AACA;AACA;;AACA,SAASC,+BAAT,QAAgD,iBAAhD;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,sBAAT,QAAuC,6BAAvC;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,aAAT,QAA8B,mBAA9B;AACA,SAASC,QAAT,QAAyB,aAAzB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,yB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EAAGyG;AAAjB,KAA+BD,OAA/B,CAAP;AACA;;AAED,MAAMK,0BAA0B,GAAGhK,UAAU,CAAEwC,eAAF,CAA7C;;AAEAwH,0BAA0B,CAACC,OAA3B,GAAqC,SAK9B;AAAA,MALgC;AACtCtH,IAAAA,KADsC;AAEtCD,IAAAA,OAAO,EAAEwH,GAF6B;AAGtCjH,IAAAA,SAHsC;AAItC,OAAGV;AAJmC,GAKhC;;AACN;AACA,MAAKuD,KAAK,CAACC,OAAN,CAAepD,KAAf,CAAL,EAA8B;AAC7BA,IAAAA,KAAK,GAAGtC,cAAc,CAAC2F,MAAf,CAAuBrD,KAAvB,CAAR;AACA;;AAED,QAAMwH,YAAY,GAAGjI,eAAe,CAAEe,SAAF,CAApC;;AAEA,MAAK,CAAEN,KAAF,IAAWwH,YAAhB,EAA+B;AAC9BxH,IAAAA,KAAK,GAAI,IAAIwH,YAAc,MAAMA,YAAc,GAA/C;AACA;;AAED,QAAMR,OAAO,GAAG,cAAC,OAAD,QAAWhH,KAAX,CAAhB;;AAEA,MAAKuH,GAAL,EAAW;AACV,WAAO,cAAC,GAAD,EAAUtK,IAAI,CAAE2C,KAAF,EAAS,CAAE,QAAF,CAAT,CAAd,EAA0CoH,OAA1C,CAAP;AACA;;AAED,SAAOA,OAAP;AACA,CAxBD;;AA0BAK,0BAA0B,CAACrJ,OAA3B,GAAuCgC,KAAF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACgD,MAAN,KAAiB,CAAnC;AACA,CAFD;AAIA;AACA;AACA;;;AACA,eAAeqE,0BAAf;AACA,SAASI,gBAAT,QAAiC,YAAjC;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AACA,SAASC,4BAAT,QAA6C,eAA7C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRawHTML,\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tisEmpty,\n\tisCollapsed,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useInputRules } from './use-input-rules';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getMultilineTag, getAllowedFormats } from './utils';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\treturn omit( props, [\n\t\t'__unstableMobileNoFocusOnMount',\n\t\t'deleteEnter',\n\t\t'placeholderTextColor',\n\t\t'textAlign',\n\t\t'selectionColor',\n\t\t'tagsToEliminate',\n\t\t'rootTagsToEliminate',\n\t\t'disableEditingMenu',\n\t\t'fontSize',\n\t\t'fontFamily',\n\t\t'fontWeight',\n\t\t'fontStyle',\n\t\t'minWidth',\n\t\t'maxWidth',\n\t\t'setRef',\n\t] );\n}\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: originalValue = '',\n\t\tonChange: originalOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\tunstableOnFocus,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } = select(\n\t\t\tblockEditorStore\n\t\t);\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst { value, onChange, ref: richTextRef } = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableMultilineTag: multilineTag,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\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\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\tif ( 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\tfunction onFocus() {\n\t\tanchorRef.current.focus();\n\t}\n\n\tconst TagName = tagName;\n\tconst content = (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\tanchorRef={ anchorRef.current }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\tonFocus={ unstableOnFocus }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tif ( ! wrapperClassName ) {\n\t\treturn content;\n\t}\n\n\tdeprecated( 'wp.blockEditor.RichText wrapperClassName prop', {\n\t\tsince: '5.4',\n\t\talternative: 'className prop or create your own wrapper div',\n\t\tversion: '6.2',\n\t} );\n\n\tconst className = classnames( 'block-editor-rich-text', wrapperClassName );\n\treturn <div className={ className }>{ content }</div>;\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = ( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\t...props\n} ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\treturn <Tag { ...omit( props, [ 'format' ] ) }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"names":["classnames","omit","RawHTML","useRef","useCallback","forwardRef","createContext","useDispatch","useSelect","children","childrenSource","useInstanceId","useMergeRefs","__unstableUseRichText","useRichText","__unstableCreateElement","isEmpty","isCollapsed","removeFormat","deprecated","BACKSPACE","DELETE","Popover","useBlockEditorAutocompleteProps","useBlockEditContext","FormatToolbarContainer","store","blockEditorStore","useUndoAutomaticChange","useMarkPersistent","usePasteHandler","useInputRules","useEnter","useFormatTypes","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useFirefoxCompat","FormatEdit","getMultilineTag","getAllowedFormats","keyboardShortcutContext","inputEventContext","removeNativeProps","props","RichTextWrapper","forwardedRef","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","formattingControls","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","unstableOnFocus","__unstableAllowPrefixTransformations","instanceId","anchorRef","clientId","selector","select","getSelectionStart","getSelectionEnd","selectionStart","selectionEnd","undefined","attributeKey","offset","selectionChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","name","addInvisibleFormats","ref","richTextRef","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableMultilineTag","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onKeyDown","event","keyCode","defaultPrevented","isReverse","hasActiveFormats","activeFormats","preventDefault","onFocus","current","focus","TagName","content","className","since","alternative","version","ForwardedRichTextContainer","Content","Tag","MultilineTag","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,OADD,EAECC,MAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,aALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,QAAQ,IAAIC,cAArB,QAA2C,mBAA3C;AACA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,oBAA5C;AACA,SACCC,qBAAqB,IAAIC,WAD1B,EAECC,uBAFD,EAGCC,OAHD,EAICC,WAJD,EAKCC,YALD,QAMO,sBANP;AAOA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,qBAAlC;AACA,SAASC,OAAT,QAAwB,uBAAxB;AAEA;AACA;AACA;;AACA,SAASC,+BAAT,QAAgD,iBAAhD;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C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BAAT,QAAsC,kBAAtC;AACA,SAASC,4BAAT,QAA6C,eAA7C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRawHTML,\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tisEmpty,\n\tisCollapsed,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useInputRules } from './use-input-rules';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getMultilineTag, getAllowedFormats } from './utils';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\treturn omit( props, [\n\t\t'__unstableMobileNoFocusOnMount',\n\t\t'deleteEnter',\n\t\t'placeholderTextColor',\n\t\t'textAlign',\n\t\t'selectionColor',\n\t\t'tagsToEliminate',\n\t\t'rootTagsToEliminate',\n\t\t'disableEditingMenu',\n\t\t'fontSize',\n\t\t'fontFamily',\n\t\t'fontWeight',\n\t\t'fontStyle',\n\t\t'minWidth',\n\t\t'maxWidth',\n\t\t'setRef',\n\t\t'disableSuggestions',\n\t\t'disableAutocorrection',\n\t] );\n}\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: originalValue = '',\n\t\tonChange: originalOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\tunstableOnFocus,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableMultilineTag: multilineTag,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\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\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\tif ( 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\tfunction onFocus() {\n\t\tanchorRef.current.focus();\n\t}\n\n\tconst TagName = tagName;\n\tconst content = (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\tanchorRef={ anchorRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\tonFocus={ unstableOnFocus }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tif ( ! wrapperClassName ) {\n\t\treturn content;\n\t}\n\n\tdeprecated( 'wp.blockEditor.RichText wrapperClassName prop', {\n\t\tsince: '5.4',\n\t\talternative: 'className prop or create your own wrapper div',\n\t\tversion: '6.2',\n\t} );\n\n\tconst className = classnames( 'block-editor-rich-text', wrapperClassName );\n\treturn <div className={ className }>{ content }</div>;\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = ( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\t...props\n} ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\treturn <Tag { ...omit( props, [ 'format' ] ) }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"]}
|
|
@@ -82,6 +82,8 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
82
82
|
maxWidth,
|
|
83
83
|
onBlur,
|
|
84
84
|
setRef,
|
|
85
|
+
disableSuggestions,
|
|
86
|
+
disableAutocorrection,
|
|
85
87
|
...props
|
|
86
88
|
} = _ref;
|
|
87
89
|
const instanceId = useInstanceId(RichTextWrapper);
|
|
@@ -538,7 +540,9 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
538
540
|
minWidth: minWidth,
|
|
539
541
|
maxWidth: maxWidth,
|
|
540
542
|
onBlur: onBlur,
|
|
541
|
-
setRef: setRef
|
|
543
|
+
setRef: setRef,
|
|
544
|
+
disableSuggestions: disableSuggestions,
|
|
545
|
+
disableAutocorrection: disableAutocorrection // Props to be set on the editable container are destructured on the
|
|
542
546
|
// element itself for web (see below), but passed through rich text
|
|
543
547
|
// for native.
|
|
544
548
|
,
|