@wordpress/block-editor 14.4.0 → 14.6.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 +4 -0
- package/README.md +4 -8
- package/build/autocompleters/block.js +13 -5
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/background-image-control/index.js +1 -1
- package/build/components/background-image-control/index.js.map +1 -1
- package/build/components/block-canvas/index.js +10 -0
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +2 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-controls/slot.native.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +1 -1
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-full-height-alignment-control/index.js +1 -1
- package/build/components/block-full-height-alignment-control/index.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.native.js +1 -1
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +1 -7
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +6 -5
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -3
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +11 -6
- 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/zoom-out-separator.js +10 -7
- package/build/components/block-list/zoom-out-separator.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-parent-selector/index.js +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +1 -1
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -4
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +2 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-rename/modal.js +2 -2
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-parent-selector-menu-item.js +1 -1
- package/build/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js +4 -3
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +1 -0
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-switcher/utils.js +1 -0
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +122 -0
- package/build/components/block-toolbar/change-design.js.map +1 -0
- package/build/components/block-toolbar/index.js +19 -7
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/index.js +4 -17
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +4 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -6
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +20 -29
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +3 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +6 -10
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +7 -10
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/collab/block-comment-icon-slot.js +18 -0
- package/build/components/collab/block-comment-icon-slot.js.map +1 -0
- package/build/components/collab/block-comment-icon-toolbar-slot.js +18 -0
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +7 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +4 -4
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -0
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/utils.js.map +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -4
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +2 -1
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-context.native.js +6 -0
- package/build/components/global-styles/use-global-styles-context.native.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/iframe/index.js +46 -11
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +1 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-size-control/index.js +61 -20
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +9 -5
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +15 -8
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -2
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +16 -12
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/media-tab/utils.js.map +1 -1
- package/build/components/inserter/menu.js +8 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +1 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inserter-button/index.native.js +1 -1
- package/build/components/inserter-button/index.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +0 -2
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +3 -6
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/is-url-like.js.map +1 -1
- package/build/components/link-control/link-preview.js +12 -9
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-create-button.js +1 -1
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-input.js +3 -5
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-results.js +5 -15
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/use-rich-url-data.js.map +1 -1
- package/build/components/list-view/appender.js +5 -4
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +6 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +1 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +2 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/utils.js +1 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +1 -1
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +2 -2
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/observe-typing/index.js +1 -0
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +1 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/responsive-block-control/index.js +3 -3
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/responsive-block-control/label.js +1 -1
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/event-listeners/index.js +3 -1
- package/build/components/rich-text/event-listeners/index.js.map +1 -1
- package/build/components/rich-text/file-paste-handler.native.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.native.js.map +1 -1
- package/build/components/rich-text/index.js +3 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -6
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/multiline.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/native/use-format-types.js +1 -0
- package/build/components/rich-text/native/use-format-types.js.map +1 -1
- package/build/components/rich-text/toolbar-button.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +1 -0
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +2 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -3
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/linked-button.js +1 -5
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/tool-selector/index.js +8 -5
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/typewriter/index.js +1 -0
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/unsupported-block-details/index.native.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +5 -5
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +0 -1
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-flash-editable-blocks/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +1 -3
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -2
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +1 -3
- package/build/components/use-settings/index.js.map +1 -1
- package/build/components/writing-flow/index.js +5 -3
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +20 -5
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/block-bindings.js +19 -8
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-hooks.js +1 -1
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/contrast-checker.js +0 -1
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/duotone.js +2 -2
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -0
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/grid-visualizer.js +13 -11
- package/build/hooks/grid-visualizer.js.map +1 -1
- package/build/hooks/layout-child.js +41 -3
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/style.js +4 -1
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/text-align.js.map +1 -1
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/use-zoom-out.js +17 -18
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/index.js +0 -7
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/grid.js.map +1 -1
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +6 -38
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/private-actions.js +57 -8
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +9 -21
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +18 -24
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +66 -22
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-bindings.js +9 -6
- package/build/utils/block-bindings.js.map +1 -1
- package/build/utils/dom.js +16 -1
- package/build/utils/dom.js.map +1 -1
- package/build/utils/get-font-styles-and-weights.js +2 -2
- package/build/utils/get-font-styles-and-weights.js.map +1 -1
- package/build/utils/object.js +1 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/pasting.js.map +1 -1
- package/build/utils/transform-styles/index.js +4 -3
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/autocompleters/block.js +15 -9
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +1 -3
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/audio-player/index.native.js +1 -2
- package/build-module/components/audio-player/index.native.js.map +1 -1
- package/build-module/components/background-image-control/index.js +2 -3
- package/build-module/components/background-image-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +1 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +1 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-canvas/index.js +12 -3
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +4 -5
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-compare/block-view.js +1 -2
- package/build-module/components/block-compare/block-view.js.map +1 -1
- package/build-module/components/block-compare/index.js +1 -2
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-controls/fill.js +1 -3
- package/build-module/components/block-controls/fill.js.map +1 -1
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-controls/slot.native.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +2 -3
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +1 -2
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +1 -3
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/index.js +1 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-edit/multiple-usage-warning.js +1 -2
- package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
- package/build-module/components/block-full-height-alignment-control/index.js +1 -1
- package/build-module/components/block-full-height-alignment-control/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -3
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-crash-warning.js +1 -1
- package/build-module/components/block-list/block-crash-warning.js.map +1 -1
- package/build-module/components/block-list/block-crash-warning.native.js +1 -1
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +1 -3
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +1 -2
- 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 +1 -2
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -4
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -9
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +7 -7
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -3
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/insertion-point.native.js +1 -2
- package/build-module/components/block-list/insertion-point.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -2
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -3
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +11 -6
- 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/zoom-out-separator.js +10 -7
- package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +1 -3
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +2 -3
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +1 -3
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +1 -2
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -3
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +1 -2
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +1 -2
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -3
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -3
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +2 -3
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +2 -7
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +3 -4
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +1 -2
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +1 -2
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +3 -4
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-rename/rename-control.js +1 -3
- package/build-module/components/block-rename/rename-control.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +1 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js +1 -1
- package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +6 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +5 -4
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -2
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +1 -2
- package/build-module/components/block-styles/menu-items.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +1 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +1 -3
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +1 -3
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
- package/build-module/components/block-switcher/index.js +3 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +1 -2
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -2
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +1 -0
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +1 -0
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -2
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +114 -0
- package/build-module/components/block-toolbar/change-design.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +20 -10
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +1 -3
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-tools/index.js +5 -19
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +5 -5
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -6
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +20 -29
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-types-list/index.js +1 -2
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +1 -2
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +1 -2
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +4 -4
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +6 -10
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +1 -3
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +8 -11
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.native.js +1 -2
- package/build-module/components/button-block-appender/index.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +1 -3
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-slot.js +11 -0
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -0
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +11 -0
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +1 -3
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +1 -3
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +1 -3
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +7 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/contrast-checker/index.native.js +1 -2
- package/build-module/components/contrast-checker/index.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +1 -3
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +5 -6
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -2
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +1 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +1 -3
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/dimensions-tool/width-height-tool.js +1 -3
- package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -1
- package/build-module/components/duotone/utils.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +1 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/floating-toolbar/index.native.js +1 -2
- package/build-module/components/floating-toolbar/index.native.js.map +1 -1
- package/build-module/components/floating-toolbar/nav-up-icon.js +1 -2
- package/build-module/components/floating-toolbar/nav-up-icon.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +2 -2
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +1 -2
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +1 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -7
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +1 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +1 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +2 -1
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +1 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +1 -2
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-context.native.js +6 -0
- package/build-module/components/global-styles/use-global-styles-context.native.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +1 -3
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/height-control/index.js +1 -2
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +47 -14
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -3
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +1 -3
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/form-controls.js +1 -3
- package/build-module/components/image-editor/form-controls.js.map +1 -1
- package/build-module/components/image-editor/index.js +1 -2
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +1 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +1 -3
- package/build-module/components/image-link-destinations/index.native.js.map +1 -1
- package/build-module/components/image-size-control/index.js +63 -24
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -9
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +1 -2
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +1 -2
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -3
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -5
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -3
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +3 -5
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +2 -4
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +1 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +18 -15
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -3
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -2
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +2 -4
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +1 -3
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/media-tab/utils.js.map +1 -1
- package/build-module/components/inserter/menu.js +10 -7
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +1 -3
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -2
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/no-results.js +1 -2
- package/build-module/components/inserter/no-results.js.map +1 -1
- package/build-module/components/inserter/no-results.native.js +1 -2
- package/build-module/components/inserter/no-results.native.js.map +1 -1
- package/build-module/components/inserter/panel.js +1 -3
- package/build-module/components/inserter/panel.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +2 -3
- package/build-module/components/inserter-button/index.native.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +1 -2
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +1 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +1 -4
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -3
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +1 -3
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +3 -6
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +1 -2
- package/build-module/components/inspector-popover-header/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -3
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/is-url-like.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +14 -13
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +1 -1
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-input.js +4 -7
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-results.js +6 -17
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -3
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -2
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/link-control/use-rich-url-data.js.map +1 -1
- package/build-module/components/list-view/appender.js +6 -6
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -3
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +1 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +8 -9
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +1 -2
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +2 -4
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +2 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/utils.js +1 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +1 -3
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +2 -4
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +1 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/media-upload-progress/index.native.js +1 -2
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +3 -4
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +1 -0
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/provider/index.js +2 -3
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +1 -2
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +1 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +4 -5
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/responsive-block-control/label.js +2 -4
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/before-input-rules.js +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/delete.js +2 -2
- package/build-module/components/rich-text/event-listeners/delete.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/enter.js +2 -2
- package/build-module/components/rich-text/event-listeners/enter.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/firefox-compat.js +2 -2
- package/build-module/components/rich-text/event-listeners/firefox-compat.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/index.js +4 -2
- package/build-module/components/rich-text/event-listeners/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/input-events.js +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.js +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/shortcuts.js +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.js +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/file-paste-handler.native.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -3
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.native.js +1 -3
- package/build-module/components/rich-text/format-toolbar/index.native.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -5
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -9
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/multiline.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.js +1 -1
- package/build-module/components/rich-text/native/index.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +1 -3
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +1 -3
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -1
- package/build-module/components/rich-text/native/use-format-types.js +1 -0
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/toolbar-button.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +1 -0
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +4 -5
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +1 -2
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +1 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -7
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/linked-button.js +2 -6
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +1 -2
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +9 -8
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -0
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/unsupported-block-details/index.native.js +1 -2
- package/build-module/components/unsupported-block-details/index.native.js.map +1 -1
- package/build-module/components/url-input/button.js +1 -2
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +2 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +1 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/index.js +1 -2
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +1 -2
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/url-popover/link-viewer.js +1 -2
- package/build-module/components/url-popover/link-viewer.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +5 -5
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +0 -1
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-flash-editable-blocks/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +1 -3
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -2
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +1 -3
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/components/video-player/index.native.js +1 -2
- package/build-module/components/video-player/index.native.js.map +1 -1
- package/build-module/components/warning/index.js +1 -2
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +1 -2
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/components/writing-flow/index.js +6 -6
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +20 -5
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -3
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/block-bindings.js +21 -12
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-hooks.js +2 -3
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +1 -2
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +0 -1
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/dimensions.js +1 -3
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -5
- package/build-module/hooks/duotone.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/generated-class-name.js +1 -0
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +14 -14
- package/build-module/hooks/grid-visualizer.js.map +1 -1
- package/build-module/hooks/layout-child.js +42 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +1 -3
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/style.js +5 -4
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/text-align.js.map +1 -1
- package/build-module/hooks/typography.native.js +1 -2
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +1 -2
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +18 -19
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +1 -3
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -3
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/grid.js +1 -3
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +6 -38
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/private-actions.js +54 -7
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +9 -20
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +17 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +66 -20
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-bindings.js +9 -6
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-module/utils/dom.js +16 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-module/utils/get-font-styles-and-weights.js +3 -3
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
- package/build-module/utils/get-px-from-css-unit.js +1 -1
- package/build-module/utils/get-px-from-css-unit.js.map +1 -1
- package/build-module/utils/object.js +1 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +3 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +19 -27
- package/build-style/content.css +19 -27
- package/build-style/style-rtl.css +47 -54
- package/build-style/style.css +47 -54
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +34 -33
- package/src/autocompleters/block.js +16 -7
- package/src/components/block-canvas/index.js +17 -1
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-card/index.js +3 -3
- package/src/components/block-full-height-alignment-control/index.js +1 -1
- package/src/components/block-inspector/style.scss +0 -6
- package/src/components/block-list/block.js +1 -2
- package/src/components/block-list/block.native.js +0 -4
- package/src/components/block-list/content.scss +4 -3
- package/src/components/block-list/index.js +4 -4
- package/src/components/block-list/use-block-props/index.js +0 -2
- package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -3
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +12 -4
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-list/zoom-out-separator.js +8 -6
- package/src/components/block-patterns-list/stories/fixtures.js +834 -0
- package/src/components/block-patterns-list/stories/index.story.js +81 -0
- package/src/components/block-patterns-list/style.scss +2 -0
- package/src/components/block-patterns-paging/index.js +1 -1
- package/src/components/block-popover/index.js +2 -2
- package/src/components/block-preview/auto.js +1 -4
- package/src/components/block-preview/index.js +2 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-settings-menu/index.js +3 -0
- package/src/components/block-toolbar/change-design.js +133 -0
- package/src/components/block-toolbar/index.js +25 -8
- package/src/components/block-toolbar/style.scss +16 -0
- package/src/components/block-tools/index.js +4 -28
- package/src/components/block-tools/insertion-point.js +4 -3
- package/src/components/block-tools/style.scss +0 -20
- package/src/components/block-tools/use-show-block-tools.js +2 -8
- package/src/components/block-tools/zoom-out-mode-inserters.js +25 -40
- package/src/components/block-variation-transforms/index.js +2 -2
- package/src/components/block-vertical-alignment-control/ui.js +11 -15
- package/src/components/border-radius-control/linked-button.js +9 -11
- package/src/components/collab/block-comment-icon-slot.js +12 -0
- package/src/components/collab/block-comment-icon-toolbar-slot.js +12 -0
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +7 -1
- package/src/components/convert-to-group-buttons/toolbar.js +4 -4
- package/src/components/global-styles/color-panel.js +2 -10
- package/src/components/global-styles/test/use-global-styles-context.native.js +1 -0
- package/src/components/global-styles/use-global-styles-context.native.js +6 -0
- package/src/components/iframe/content.scss +22 -32
- package/src/components/iframe/index.js +62 -15
- package/src/components/iframe/style.scss +17 -0
- package/src/components/image-size-control/index.js +74 -43
- package/src/components/image-size-control/test/index.js +5 -63
- package/src/components/inner-blocks/index.js +12 -6
- package/src/components/inner-blocks/use-nested-settings-update.js +16 -10
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +1 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -3
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/src/components/inserter/category-tabs/index.js +17 -13
- package/src/components/inserter/menu.js +12 -5
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/style.scss +14 -41
- package/src/components/inserter-button/index.native.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +1 -6
- package/src/components/inspector-controls-tabs/utils.js +0 -3
- package/src/components/link-control/link-preview.js +15 -8
- package/src/components/link-control/search-input.js +4 -5
- package/src/components/link-control/search-results.js +2 -13
- package/src/components/link-control/test/index.js +147 -70
- package/src/components/list-view/appender.js +5 -6
- package/src/components/list-view/branch.js +8 -6
- package/src/components/list-view/index.js +1 -2
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/provider/index.js +1 -3
- package/src/components/provider/test/experimental-provider.js +43 -1
- package/src/components/responsive-block-control/style.scss +0 -1
- package/src/components/rich-text/event-listeners/index.js +4 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +5 -0
- package/src/components/spacing-sizes-control/index.js +3 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
- package/src/components/spacing-sizes-control/linked-button.js +2 -12
- package/src/components/tool-selector/index.js +6 -5
- package/src/components/url-input/index.js +1 -1
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +5 -5
- package/src/components/use-block-drop-zone/index.native.js +0 -1
- package/src/components/use-moving-animation/index.js +0 -1
- package/src/components/use-resize-canvas/index.js +1 -3
- package/src/components/use-settings/index.js +0 -1
- package/src/components/writing-flow/index.js +5 -3
- package/src/components/writing-flow/use-tab-nav.js +27 -4
- package/src/hooks/block-bindings.js +48 -31
- package/src/hooks/contrast-checker.js +0 -1
- package/src/hooks/duotone.js +2 -2
- package/src/hooks/grid-visualizer.js +23 -9
- package/src/hooks/layout-child.js +48 -3
- package/src/hooks/style.js +7 -3
- package/src/hooks/use-zoom-out.js +20 -24
- package/src/index.js +0 -1
- package/src/private-apis.js +6 -1
- package/src/store/actions.js +5 -53
- package/src/store/defaults.js +2 -1
- package/src/store/private-actions.js +71 -8
- package/src/store/private-selectors.js +9 -19
- package/src/store/reducer.js +25 -28
- package/src/store/selectors.js +82 -20
- package/src/store/test/actions.js +41 -0
- package/src/store/test/private-selectors.js +7 -1
- package/src/store/test/reducer.js +23 -0
- package/src/store/test/selectors.js +13 -2
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.js +9 -6
- package/src/utils/dom.js +22 -2
- package/src/utils/get-font-styles-and-weights.js +2 -2
- package/src/utils/test/use-block-bindings-utils.js +174 -0
- package/src/utils/transform-styles/index.js +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +0 -57
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +0 -1
- package/build/components/block-toolbar/shuffle.js +0 -110
- package/build/components/block-toolbar/shuffle.js.map +0 -1
- package/build/components/block-tools/zoom-out-popover.js +0 -57
- package/build/components/block-tools/zoom-out-popover.js.map +0 -1
- package/build/components/block-tools/zoom-out-toolbar.js +0 -149
- package/build/components/block-tools/zoom-out-toolbar.js.map +0 -1
- package/build/components/block-vertical-alignment-control/icons.js +0 -48
- package/build/components/block-vertical-alignment-control/icons.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +0 -51
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +0 -1
- package/build-module/components/block-toolbar/shuffle.js +0 -103
- package/build-module/components/block-toolbar/shuffle.js.map +0 -1
- package/build-module/components/block-tools/zoom-out-popover.js +0 -48
- package/build-module/components/block-tools/zoom-out-popover.js.map +0 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +0 -142
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +0 -1
- package/build-module/components/block-vertical-alignment-control/icons.js +0 -41
- package/build-module/components/block-vertical-alignment-control/icons.js.map +0 -1
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +0 -65
- package/src/components/block-toolbar/shuffle.js +0 -111
- package/src/components/block-tools/zoom-out-popover.js +0 -46
- package/src/components/block-tools/zoom-out-toolbar.js +0 -156
- package/src/components/block-vertical-alignment-control/icons.js +0 -34
|
@@ -38,6 +38,8 @@ function isObjectEmpty(object) {
|
|
|
38
38
|
*
|
|
39
39
|
* @since 6.7.0 Introduced in WordPress core.
|
|
40
40
|
*
|
|
41
|
+
* @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.
|
|
42
|
+
*
|
|
41
43
|
* @return {?WPBlockBindingsUtils} Object containing the block bindings utils.
|
|
42
44
|
*
|
|
43
45
|
* @example
|
|
@@ -68,10 +70,11 @@ function isObjectEmpty(object) {
|
|
|
68
70
|
* removeAllBlockBindings();
|
|
69
71
|
* ```
|
|
70
72
|
*/
|
|
71
|
-
function useBlockBindingsUtils() {
|
|
73
|
+
function useBlockBindingsUtils(clientId) {
|
|
72
74
|
const {
|
|
73
|
-
clientId
|
|
75
|
+
clientId: contextClientId
|
|
74
76
|
} = (0, _blockEdit.useBlockEditContext)();
|
|
77
|
+
const blockClientId = clientId || contextClientId;
|
|
75
78
|
const {
|
|
76
79
|
updateBlockAttributes
|
|
77
80
|
} = (0, _data.useDispatch)(_store.store);
|
|
@@ -114,7 +117,7 @@ function useBlockBindingsUtils() {
|
|
|
114
117
|
bindings: currentBindings,
|
|
115
118
|
...metadata
|
|
116
119
|
} = {}
|
|
117
|
-
} = getBlockAttributes(
|
|
120
|
+
} = getBlockAttributes(blockClientId);
|
|
118
121
|
const newBindings = {
|
|
119
122
|
...currentBindings
|
|
120
123
|
};
|
|
@@ -132,7 +135,7 @@ function useBlockBindingsUtils() {
|
|
|
132
135
|
if (isObjectEmpty(newMetadata.bindings)) {
|
|
133
136
|
delete newMetadata.bindings;
|
|
134
137
|
}
|
|
135
|
-
updateBlockAttributes(
|
|
138
|
+
updateBlockAttributes(blockClientId, {
|
|
136
139
|
metadata: isObjectEmpty(newMetadata) ? undefined : newMetadata
|
|
137
140
|
});
|
|
138
141
|
};
|
|
@@ -154,8 +157,8 @@ function useBlockBindingsUtils() {
|
|
|
154
157
|
bindings,
|
|
155
158
|
...metadata
|
|
156
159
|
} = {}
|
|
157
|
-
} = getBlockAttributes(
|
|
158
|
-
updateBlockAttributes(
|
|
160
|
+
} = getBlockAttributes(blockClientId);
|
|
161
|
+
updateBlockAttributes(blockClientId, {
|
|
159
162
|
metadata: isObjectEmpty(metadata) ? undefined : metadata
|
|
160
163
|
});
|
|
161
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_store","_blockEdit","isObjectEmpty","object","Object","keys","length","useBlockBindingsUtils","clientId","useBlockEditContext","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","useRegistry","select","updateBlockBindings","bindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Contains utils to update the block `bindings` metadata.\n *\n * @typedef {Object} WPBlockBindingsUtils\n *\n * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.\n * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.\n */\n\n/**\n * Retrieves the existing utils needed to update the block `bindings` metadata.\n * They can be used to create, modify, or remove connections from the existing block attributes.\n *\n * It contains the following utils:\n * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.\n * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.\n *\n * @since 6.7.0 Introduced in WordPress core.\n *\n * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.\n *\n * @example\n * ```js\n * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();\n *\n * // Update url and alt attributes.\n * updateBlockBindings( {\n * url: {\n * source: 'core/post-meta',\n * args: {\n * key: 'url_custom_field',\n * },\n * },\n * alt: {\n * source: 'core/post-meta',\n * args: {\n * key: 'text_custom_field',\n * },\n * },\n * } );\n *\n * // Remove binding from url attribute.\n * updateBlockBindings( { url: undefined } );\n *\n * // Remove bindings from all attributes.\n * removeAllBlockBindings();\n * ```\n */\nexport function useBlockBindingsUtils() {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes(
|
|
1
|
+
{"version":3,"names":["_data","require","_store","_blockEdit","isObjectEmpty","object","Object","keys","length","useBlockBindingsUtils","clientId","contextClientId","useBlockEditContext","blockClientId","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","useRegistry","select","updateBlockBindings","bindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Contains utils to update the block `bindings` metadata.\n *\n * @typedef {Object} WPBlockBindingsUtils\n *\n * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.\n * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.\n */\n\n/**\n * Retrieves the existing utils needed to update the block `bindings` metadata.\n * They can be used to create, modify, or remove connections from the existing block attributes.\n *\n * It contains the following utils:\n * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.\n * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.\n *\n * @since 6.7.0 Introduced in WordPress core.\n *\n * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.\n *\n * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.\n *\n * @example\n * ```js\n * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();\n *\n * // Update url and alt attributes.\n * updateBlockBindings( {\n * url: {\n * source: 'core/post-meta',\n * args: {\n * key: 'url_custom_field',\n * },\n * },\n * alt: {\n * source: 'core/post-meta',\n * args: {\n * key: 'text_custom_field',\n * },\n * },\n * } );\n *\n * // Remove binding from url attribute.\n * updateBlockBindings( { url: undefined } );\n *\n * // Remove bindings from all attributes.\n * removeAllBlockBindings();\n * ```\n */\nexport function useBlockBindingsUtils( clientId ) {\n\tconst { clientId: contextClientId } = useBlockEditContext();\n\tconst blockClientId = clientId || contextClientId;\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASG,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;;AAEA;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;AACO,SAASC,qBAAqBA,CAAEC,QAAQ,EAAG;EACjD,MAAM;IAAEA,QAAQ,EAAEC;EAAgB,CAAC,GAAG,IAAAC,8BAAmB,EAAC,CAAC;EAC3D,MAAMC,aAAa,GAAGH,QAAQ,IAAIC,eAAe;EACjD,MAAM;IAAEG;EAAsB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACjE,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,iBAAW,EAAC,CAAC,CAACC,MAAM,CAAEH,YAAiB,CAAC;;EAEvE;AACD;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;EACC,MAAMI,mBAAmB,GAAKC,QAAQ,IAAM;IAC3C,MAAM;MAAEC,QAAQ,EAAE;QAAED,QAAQ,EAAEE,eAAe;QAAE,GAAGD;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GAClEL,kBAAkB,CAAEJ,aAAc,CAAC;IACpC,MAAMW,WAAW,GAAG;MAAE,GAAGD;IAAgB,CAAC;IAE1CjB,MAAM,CAACmB,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAE,CAAE,CAAEC,SAAS,EAAEC,OAAO,CAAE,KAAM;MACjE,IAAK,CAAEA,OAAO,IAAIJ,WAAW,CAAEG,SAAS,CAAE,EAAG;QAC5C,OAAOH,WAAW,CAAEG,SAAS,CAAE;QAC/B;MACD;MACAH,WAAW,CAAEG,SAAS,CAAE,GAAGC,OAAO;IACnC,CAAE,CAAC;IAEH,MAAMC,WAAW,GAAG;MACnB,GAAGP,QAAQ;MACXD,QAAQ,EAAEG;IACX,CAAC;IAED,IAAKpB,aAAa,CAAEyB,WAAW,CAACR,QAAS,CAAC,EAAG;MAC5C,OAAOQ,WAAW,CAACR,QAAQ;IAC5B;IAEAP,qBAAqB,CAAED,aAAa,EAAE;MACrCS,QAAQ,EAAElB,aAAa,CAAEyB,WAAY,CAAC,GAAGC,SAAS,GAAGD;IACtD,CAAE,CAAC;EACJ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAME,sBAAsB,GAAGA,CAAA,KAAM;IACpC,MAAM;MAAET,QAAQ,EAAE;QAAED,QAAQ;QAAE,GAAGC;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GACjDL,kBAAkB,CAAEJ,aAAc,CAAC;IACpCC,qBAAqB,CAAED,aAAa,EAAE;MACrCS,QAAQ,EAAElB,aAAa,CAAEkB,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAEF,mBAAmB;IAAEW;EAAuB,CAAC;AACvD","ignoreList":[]}
|
package/build/utils/dom.js
CHANGED
|
@@ -113,6 +113,17 @@ function isElementVisible(element) {
|
|
|
113
113
|
return true;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Checks if the element is scrollable.
|
|
118
|
+
*
|
|
119
|
+
* @param {Element} element Element.
|
|
120
|
+
* @return {boolean} True if the element is scrollable.
|
|
121
|
+
*/
|
|
122
|
+
function isScrollable(element) {
|
|
123
|
+
const style = window.getComputedStyle(element);
|
|
124
|
+
return style.overflowX === 'auto' || style.overflowX === 'scroll' || style.overflowY === 'auto' || style.overflowY === 'scroll';
|
|
125
|
+
}
|
|
126
|
+
|
|
116
127
|
/**
|
|
117
128
|
* Returns the rect of the element including all visible nested elements.
|
|
118
129
|
*
|
|
@@ -140,7 +151,11 @@ function getVisibleElementBounds(element) {
|
|
|
140
151
|
while (currentElement = stack.pop()) {
|
|
141
152
|
for (const child of currentElement.children) {
|
|
142
153
|
if (isElementVisible(child)) {
|
|
143
|
-
|
|
154
|
+
let childBounds = child.getBoundingClientRect();
|
|
155
|
+
// If the parent is scrollable, use parent's scrollable bounds.
|
|
156
|
+
if (isScrollable(currentElement)) {
|
|
157
|
+
childBounds = currentElement.getBoundingClientRect();
|
|
158
|
+
}
|
|
144
159
|
bounds = rectUnion(bounds, childBounds);
|
|
145
160
|
stack.push(child);
|
|
146
161
|
}
|
package/build/utils/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BLOCK_SELECTOR","APPENDER_SELECTOR","BLOCK_APPENDER_CLASS","isInSameBlock","a","b","closest","isInsideRootBlock","blockElement","element","parentBlock","join","getBlockClientId","node","nodeType","ELEMENT_NODE","parentNode","elementNode","blockNode","id","slice","length","rectUnion","rect1","rect2","left","Math","min","right","max","bottom","top","window","DOMRectReadOnly","isElementVisible","viewport","ownerDocument","defaultView","classList","contains","bounds","getBoundingClientRect","width","height","checkVisibility","opacityProperty","contentVisibilityAuto","visibilityProperty","style","getComputedStyle","display","visibility","opacity","getVisibleElementBounds","stack","currentElement","pop","child","children","childBounds","push","innerWidth"],"sources":["@wordpress/block-editor/src/utils/dom.js"],"sourcesContent":["const BLOCK_SELECTOR = '.block-editor-block-list__block';\nconst APPENDER_SELECTOR = '.block-list-appender';\nconst BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';\n\n/**\n * Returns true if two elements are contained within the same block.\n *\n * @param {Element} a First element.\n * @param {Element} b Second element.\n *\n * @return {boolean} Whether elements are in the same block.\n */\nexport function isInSameBlock( a, b ) {\n\treturn a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );\n}\n\n/**\n * Returns true if an element is considered part of the block and not its inner\n * blocks or appender.\n *\n * @param {Element} blockElement Block container element.\n * @param {Element} element Element.\n *\n * @return {boolean} Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement, element ) {\n\tconst parentBlock = element.closest(\n\t\t[ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )\n\t);\n\treturn parentBlock === blockElement;\n}\n\n/**\n * Finds the block client ID given any DOM node inside the block.\n *\n * @param {Node?} node DOM node.\n *\n * @return {string|undefined} Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node ) {\n\twhile ( node && node.nodeType !== node.ELEMENT_NODE ) {\n\t\tnode = node.parentNode;\n\t}\n\n\tif ( ! node ) {\n\t\treturn;\n\t}\n\n\tconst elementNode = /** @type {Element} */ ( node );\n\tconst blockNode = elementNode.closest( BLOCK_SELECTOR );\n\n\tif ( ! blockNode ) {\n\t\treturn;\n\t}\n\n\treturn blockNode.id.slice( 'block-'.length );\n}\n\n/**\n * Calculates the union of two rectangles.\n *\n * @param {DOMRect} rect1 First rectangle.\n * @param {DOMRect} rect2 Second rectangle.\n * @return {DOMRect} Union of the two rectangles.\n */\nexport function rectUnion( rect1, rect2 ) {\n\tconst left = Math.min( rect1.left, rect2.left );\n\tconst right = Math.max( rect1.right, rect2.right );\n\tconst bottom = Math.max( rect1.bottom, rect2.bottom );\n\tconst top = Math.min( rect1.top, rect2.top );\n\n\treturn new window.DOMRectReadOnly( left, top, right - left, bottom - top );\n}\n\n/**\n * Returns whether an element is visible.\n *\n * @param {Element} element Element.\n * @return {boolean} Whether the element is visible.\n */\nfunction isElementVisible( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> component.\n\tif ( element.classList.contains( 'components-visually-hidden' ) ) {\n\t\treturn false;\n\t}\n\n\tconst bounds = element.getBoundingClientRect();\n\tif ( bounds.width === 0 || bounds.height === 0 ) {\n\t\treturn false;\n\t}\n\n\t// Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.\n\tif ( element.checkVisibility ) {\n\t\treturn element.checkVisibility?.( {\n\t\t\topacityProperty: true,\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tvisibilityProperty: true,\n\t\t} );\n\t}\n\n\tconst style = viewport.getComputedStyle( element );\n\n\tif (\n\t\tstyle.display === 'none' ||\n\t\tstyle.visibility === 'hidden' ||\n\t\tstyle.opacity === '0'\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns the rect of the element including all visible nested elements.\n *\n * Visible nested elements, including elements that overflow the parent, are\n * taken into account.\n *\n * This function is useful for calculating the visible area of a block that\n * contains nested elements that overflow the block, e.g. the Navigation block,\n * which can contain overflowing Submenu blocks.\n *\n * The returned rect represents the full extent of the element and its visible\n * children, which may extend beyond the viewport.\n *\n * @param {Element} element Element.\n * @return {DOMRect} Bounding client rect of the element and its visible children.\n */\nexport function getVisibleElementBounds( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\n\tconst stack = [ element ];\n\tlet currentElement;\n\n\twhile ( ( currentElement = stack.pop() ) ) {\n\t\tfor ( const child of currentElement.children ) {\n\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\tconst childBounds = child.getBoundingClientRect();\n\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\tstack.push( child );\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Take into account the outer horizontal limits of the container in which\n\t * an element is supposed to be \"visible\". For example, if an element is\n\t * positioned -10px to the left of the window x value (0), this function\n\t * discounts the negative overhang because it's not visible and therefore\n\t * not to be counted in the visibility calculations. Top and bottom values\n\t * are not accounted for to accommodate vertical scroll.\n\t */\n\tconst left = Math.max( bounds.left, 0 );\n\tconst right = Math.min( bounds.right, viewport.innerWidth );\n\tbounds = new window.DOMRectReadOnly(\n\t\tleft,\n\t\tbounds.top,\n\t\tright - left,\n\t\tbounds.height\n\t);\n\n\treturn bounds;\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,cAAc,GAAG,iCAAiC;AACxD,MAAMC,iBAAiB,GAAG,sBAAsB;AAChD,MAAMC,oBAAoB,GAAG,qCAAqC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrC,OAAOD,CAAC,CAACE,OAAO,CAAEN,cAAe,CAAC,KAAKK,CAAC,CAACC,OAAO,CAAEN,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,iBAAiBA,CAAEC,YAAY,EAAEC,OAAO,EAAG;EAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACH,OAAO,CAClC,CAAEN,cAAc,EAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,CAACS,IAAI,CAAE,GAAI,CACvE,CAAC;EACD,OAAOD,WAAW,KAAKF,YAAY;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,gBAAgBA,CAAEC,IAAI,EAAG;EACxC,OAAQA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY,EAAG;IACrDF,IAAI,GAAGA,IAAI,CAACG,UAAU;EACvB;EAEA,IAAK,CAAEH,IAAI,EAAG;IACb;EAC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IAAI,CAAEH,KAAM,CAAC;MACpB;IACD;EACD;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMhC,IAAI,GAAGC,IAAI,CAACG,GAAG,CAAEW,MAAM,CAACf,IAAI,EAAE,CAAE,CAAC;EACvC,MAAMG,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAEa,MAAM,CAACZ,KAAK,EAAEO,QAAQ,CAAC0B,UAAW,CAAC;EAC3DrB,MAAM,GAAG,IAAIR,MAAM,CAACC,eAAe,CAClCR,IAAI,EACJe,MAAM,CAACT,GAAG,EACVH,KAAK,GAAGH,IAAI,EACZe,MAAM,CAACG,MACR,CAAC;EAED,OAAOH,MAAM;AACd","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BLOCK_SELECTOR","APPENDER_SELECTOR","BLOCK_APPENDER_CLASS","isInSameBlock","a","b","closest","isInsideRootBlock","blockElement","element","parentBlock","join","getBlockClientId","node","nodeType","ELEMENT_NODE","parentNode","elementNode","blockNode","id","slice","length","rectUnion","rect1","rect2","left","Math","min","right","max","bottom","top","window","DOMRectReadOnly","isElementVisible","viewport","ownerDocument","defaultView","classList","contains","bounds","getBoundingClientRect","width","height","checkVisibility","opacityProperty","contentVisibilityAuto","visibilityProperty","style","getComputedStyle","display","visibility","opacity","isScrollable","overflowX","overflowY","getVisibleElementBounds","stack","currentElement","pop","child","children","childBounds","push","innerWidth"],"sources":["@wordpress/block-editor/src/utils/dom.js"],"sourcesContent":["const BLOCK_SELECTOR = '.block-editor-block-list__block';\nconst APPENDER_SELECTOR = '.block-list-appender';\nconst BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';\n\n/**\n * Returns true if two elements are contained within the same block.\n *\n * @param {Element} a First element.\n * @param {Element} b Second element.\n *\n * @return {boolean} Whether elements are in the same block.\n */\nexport function isInSameBlock( a, b ) {\n\treturn a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );\n}\n\n/**\n * Returns true if an element is considered part of the block and not its inner\n * blocks or appender.\n *\n * @param {Element} blockElement Block container element.\n * @param {Element} element Element.\n *\n * @return {boolean} Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement, element ) {\n\tconst parentBlock = element.closest(\n\t\t[ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )\n\t);\n\treturn parentBlock === blockElement;\n}\n\n/**\n * Finds the block client ID given any DOM node inside the block.\n *\n * @param {Node?} node DOM node.\n *\n * @return {string|undefined} Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node ) {\n\twhile ( node && node.nodeType !== node.ELEMENT_NODE ) {\n\t\tnode = node.parentNode;\n\t}\n\n\tif ( ! node ) {\n\t\treturn;\n\t}\n\n\tconst elementNode = /** @type {Element} */ ( node );\n\tconst blockNode = elementNode.closest( BLOCK_SELECTOR );\n\n\tif ( ! blockNode ) {\n\t\treturn;\n\t}\n\n\treturn blockNode.id.slice( 'block-'.length );\n}\n\n/**\n * Calculates the union of two rectangles.\n *\n * @param {DOMRect} rect1 First rectangle.\n * @param {DOMRect} rect2 Second rectangle.\n * @return {DOMRect} Union of the two rectangles.\n */\nexport function rectUnion( rect1, rect2 ) {\n\tconst left = Math.min( rect1.left, rect2.left );\n\tconst right = Math.max( rect1.right, rect2.right );\n\tconst bottom = Math.max( rect1.bottom, rect2.bottom );\n\tconst top = Math.min( rect1.top, rect2.top );\n\n\treturn new window.DOMRectReadOnly( left, top, right - left, bottom - top );\n}\n\n/**\n * Returns whether an element is visible.\n *\n * @param {Element} element Element.\n * @return {boolean} Whether the element is visible.\n */\nfunction isElementVisible( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> component.\n\tif ( element.classList.contains( 'components-visually-hidden' ) ) {\n\t\treturn false;\n\t}\n\n\tconst bounds = element.getBoundingClientRect();\n\tif ( bounds.width === 0 || bounds.height === 0 ) {\n\t\treturn false;\n\t}\n\n\t// Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.\n\tif ( element.checkVisibility ) {\n\t\treturn element.checkVisibility?.( {\n\t\t\topacityProperty: true,\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tvisibilityProperty: true,\n\t\t} );\n\t}\n\n\tconst style = viewport.getComputedStyle( element );\n\n\tif (\n\t\tstyle.display === 'none' ||\n\t\tstyle.visibility === 'hidden' ||\n\t\tstyle.opacity === '0'\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Checks if the element is scrollable.\n *\n * @param {Element} element Element.\n * @return {boolean} True if the element is scrollable.\n */\nfunction isScrollable( element ) {\n\tconst style = window.getComputedStyle( element );\n\treturn (\n\t\tstyle.overflowX === 'auto' ||\n\t\tstyle.overflowX === 'scroll' ||\n\t\tstyle.overflowY === 'auto' ||\n\t\tstyle.overflowY === 'scroll'\n\t);\n}\n\n/**\n * Returns the rect of the element including all visible nested elements.\n *\n * Visible nested elements, including elements that overflow the parent, are\n * taken into account.\n *\n * This function is useful for calculating the visible area of a block that\n * contains nested elements that overflow the block, e.g. the Navigation block,\n * which can contain overflowing Submenu blocks.\n *\n * The returned rect represents the full extent of the element and its visible\n * children, which may extend beyond the viewport.\n *\n * @param {Element} element Element.\n * @return {DOMRect} Bounding client rect of the element and its visible children.\n */\nexport function getVisibleElementBounds( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\tconst stack = [ element ];\n\tlet currentElement;\n\n\twhile ( ( currentElement = stack.pop() ) ) {\n\t\tfor ( const child of currentElement.children ) {\n\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\tlet childBounds = child.getBoundingClientRect();\n\t\t\t\t// If the parent is scrollable, use parent's scrollable bounds.\n\t\t\t\tif ( isScrollable( currentElement ) ) {\n\t\t\t\t\tchildBounds = currentElement.getBoundingClientRect();\n\t\t\t\t}\n\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\tstack.push( child );\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Take into account the outer horizontal limits of the container in which\n\t * an element is supposed to be \"visible\". For example, if an element is\n\t * positioned -10px to the left of the window x value (0), this function\n\t * discounts the negative overhang because it's not visible and therefore\n\t * not to be counted in the visibility calculations. Top and bottom values\n\t * are not accounted for to accommodate vertical scroll.\n\t */\n\tconst left = Math.max( bounds.left, 0 );\n\tconst right = Math.min( bounds.right, viewport.innerWidth );\n\tbounds = new window.DOMRectReadOnly(\n\t\tleft,\n\t\tbounds.top,\n\t\tright - left,\n\t\tbounds.height\n\t);\n\n\treturn bounds;\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,cAAc,GAAG,iCAAiC;AACxD,MAAMC,iBAAiB,GAAG,sBAAsB;AAChD,MAAMC,oBAAoB,GAAG,qCAAqC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrC,OAAOD,CAAC,CAACE,OAAO,CAAEN,cAAe,CAAC,KAAKK,CAAC,CAACC,OAAO,CAAEN,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,iBAAiBA,CAAEC,YAAY,EAAEC,OAAO,EAAG;EAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACH,OAAO,CAClC,CAAEN,cAAc,EAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,CAACS,IAAI,CAAE,GAAI,CACvE,CAAC;EACD,OAAOD,WAAW,KAAKF,YAAY;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,gBAAgBA,CAAEC,IAAI,EAAG;EACxC,OAAQA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY,EAAG;IACrDF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CAAC;EAC5C,MAAMgB,KAAK,GAAG,CAAEhD,OAAO,CAAE;EACzB,IAAIiD,cAAc;EAElB,OAAUA,cAAc,GAAGD,KAAK,CAACE,GAAG,CAAC,CAAC,EAAK;IAC1C,KAAM,MAAMC,KAAK,IAAIF,cAAc,CAACG,QAAQ,EAAG;MAC9C,IAAK3B,gBAAgB,CAAE0B,KAAM,CAAC,EAAG;QAChC,IAAIE,WAAW,GAAGF,KAAK,CAACnB,qBAAqB,CAAC,CAAC;QAC/C;QACA,IAAKY,YAAY,CAAEK,cAAe,CAAC,EAAG;UACrCI,WAAW,GAAGJ,cAAc,CAACjB,qBAAqB,CAAC,CAAC;QACrD;QACAD,MAAM,GAAGlB,SAAS,CAAEkB,MAAM,EAAEsB,WAAY,CAAC;QACzCL,KAAK,CAACM,IAAI,CAAEH,KAAM,CAAC;MACpB;IACD;EACD;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMnC,IAAI,GAAGC,IAAI,CAACG,GAAG,CAAEW,MAAM,CAACf,IAAI,EAAE,CAAE,CAAC;EACvC,MAAMG,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAEa,MAAM,CAACZ,KAAK,EAAEO,QAAQ,CAAC6B,UAAW,CAAC;EAC3DxB,MAAM,GAAG,IAAIR,MAAM,CAACC,eAAe,CAClCR,IAAI,EACJe,MAAM,CAACT,GAAG,EACVH,KAAK,GAAGH,IAAI,EACZe,MAAM,CAACG,MACR,CAAC;EAED,OAAOH,MAAM;AACd","ignoreList":[]}
|
|
@@ -144,8 +144,8 @@ function getFontStylesAndWeights(fontFamilyFaces) {
|
|
|
144
144
|
name: weightName,
|
|
145
145
|
value: weightValue
|
|
146
146
|
}) => {
|
|
147
|
-
const optionName = styleValue === 'normal' ? weightName : (0, _i18n.sprintf)(
|
|
148
|
-
(0, _i18n.
|
|
147
|
+
const optionName = styleValue === 'normal' ? weightName : (0, _i18n.sprintf)(/* translators: 1: Font weight name. 2: Font style name. */
|
|
148
|
+
(0, _i18n._x)('%1$s %2$s', 'font'), weightName, styleName);
|
|
149
149
|
combinedStyleAndWeightOptions.push({
|
|
150
150
|
key: `${styleValue}-${weightValue}`,
|
|
151
151
|
name: optionName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_formatFontStyle","_formatFontWeight","FONT_STYLES","name","_x","value","FONT_WEIGHTS","getFontStylesAndWeights","fontFamilyFaces","fontStyles","fontWeights","combinedStyleAndWeightOptions","isSystemFont","length","isVariableFont","forEach","face","fontWeight","test","trim","startValue","endValue","split","parseInt","slice","i","fontWeightValue","toString","some","weight","push","formatFontWeight","fontStyle","formatFontStyle","Object","keys","style","styleName","styleValue","weightName","weightValue","optionName","sprintf","__","key"],"sources":["@wordpress/block-editor/src/utils/get-font-styles-and-weights.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param {Array} fontFamilyFaces font family faces array\n * @return {Object} new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights( fontFamilyFaces ) {\n\tlet fontStyles = [];\n\tlet fontWeights = [];\n\tconst combinedStyleAndWeightOptions = [];\n\tconst isSystemFont = ! fontFamilyFaces || fontFamilyFaces?.length === 0;\n\tlet isVariableFont = false;\n\n\tfontFamilyFaces?.forEach( ( face ) => {\n\t\t// Check for variable font by looking for a space in the font weight value. e.g. \"100 900\"\n\t\tif (\n\t\t\t'string' === typeof face.fontWeight &&\n\t\t\t/\\s/.test( face.fontWeight.trim() )\n\t\t) {\n\t\t\tisVariableFont = true;\n\n\t\t\t// Find font weight start and end values.\n\t\t\tlet [ startValue, endValue ] = face.fontWeight.split( ' ' );\n\t\t\tstartValue = parseInt( startValue.slice( 0, 1 ) );\n\t\t\tif ( endValue === '1000' ) {\n\t\t\t\tendValue = 10;\n\t\t\t} else {\n\t\t\t\tendValue = parseInt( endValue.slice( 0, 1 ) );\n\t\t\t}\n\n\t\t\t// Create font weight options for available variable weights.\n\t\t\tfor ( let i = startValue; i <= endValue; i++ ) {\n\t\t\t\tconst fontWeightValue = `${ i.toString() }00`;\n\t\t\t\tif (\n\t\t\t\t\t! fontWeights.some(\n\t\t\t\t\t\t( weight ) => weight.value === fontWeightValue\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfontWeights.push( formatFontWeight( fontWeightValue ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Format font style and weight values.\n\t\tconst fontWeight = formatFontWeight(\n\t\t\t'number' === typeof face.fontWeight\n\t\t\t\t? face.fontWeight.toString()\n\t\t\t\t: face.fontWeight\n\t\t);\n\t\tconst fontStyle = formatFontStyle( face.fontStyle );\n\n\t\t// Create font style and font weight lists without duplicates.\n\t\tif ( fontStyle && Object.keys( fontStyle ).length ) {\n\t\t\tif (\n\t\t\t\t! fontStyles.some(\n\t\t\t\t\t( style ) => style.value === fontStyle.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfontStyles.push( fontStyle );\n\t\t\t}\n\t\t}\n\n\t\tif ( fontWeight && Object.keys( fontWeight ).length ) {\n\t\t\tif (\n\t\t\t\t! fontWeights.some(\n\t\t\t\t\t( weight ) => weight.value === fontWeight.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( ! isVariableFont ) {\n\t\t\t\t\tfontWeights.push( fontWeight );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// If there is no font weight of 600 or above, then include faux bold as an option.\n\tif ( ! fontWeights.some( ( weight ) => weight.value >= '600' ) ) {\n\t\tfontWeights.push( {\n\t\t\tname: _x( 'Bold', 'font weight' ),\n\t\t\tvalue: '700',\n\t\t} );\n\t}\n\n\t// If there is no italic font style, then include faux italic as an option.\n\tif ( ! fontStyles.some( ( style ) => style.value === 'italic' ) ) {\n\t\tfontStyles.push( {\n\t\t\tname: _x( 'Italic', 'font style' ),\n\t\t\tvalue: 'italic',\n\t\t} );\n\t}\n\n\t// Use default font styles and weights for system fonts.\n\tif ( isSystemFont ) {\n\t\tfontStyles = FONT_STYLES;\n\t\tfontWeights = FONT_WEIGHTS;\n\t}\n\n\t// Use default styles and weights if there are no available styles or weights from the provided font faces.\n\tfontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;\n\tfontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;\n\n\t// Generate combined font style and weight options for available fonts.\n\tfontStyles.forEach( ( { name: styleName, value: styleValue } ) => {\n\t\tfontWeights.forEach( ( { name: weightName, value: weightValue } ) => {\n\t\t\tconst optionName =\n\t\t\t\tstyleValue === 'normal'\n\t\t\t\t\t? weightName\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Font weight name. 2: Font style name. */\n\t\t\t\t\t\t\t__( '%1$s %2$s' ),\n\t\t\t\t\t\t\tweightName,\n\t\t\t\t\t\t\tstyleName\n\t\t\t\t\t );\n\n\t\t\tcombinedStyleAndWeightOptions.push( {\n\t\t\t\tkey: `${ styleValue }-${ weightValue }`,\n\t\t\t\tname: optionName,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontStyle: styleValue,\n\t\t\t\t\tfontWeight: weightValue,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t} );\n\n\treturn {\n\t\tfontStyles,\n\t\tfontWeights,\n\t\tcombinedStyleAndWeightOptions,\n\t\tisSystemFont,\n\t\tisVariableFont,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,MAAMG,WAAW,GAAG,CACnB;EACCC,IAAI,EAAE,IAAAC,QAAE,EAAE,SAAS,EAAE,YAAa,CAAC;EACnCC,KAAK,EAAE;AACR,CAAC,EACD;EACCF,IAAI,EAAE,IAAAC,QAAE,EAAE,QAAQ,EAAE,YAAa,CAAC;EAClCC,KAAK,EAAE;AACR,CAAC,CACD;AAED,MAAMC,YAAY,GAAG,CACpB;EACCH,IAAI,EAAE,IAAAC,QAAE,EAAE,MAAM,EAAE,aAAc,CAAC;EACjCC,KAAK,EAAE;AACR,CAAC,EACD;EACCF,IAAI,EAAE,IAAAC,QAAE,EAAE,aAAa,EAAE,aAAc,CAAC;EACxCC,KAAK,EAAE;AACR,CAAC,EACD;EACCF,IAAI,EAAE,IAAAC,QAAE,EAAE,OAAO,EAAE,aAAc,CAAC;EAClCC,KAAK,EAAE;AACR,CAAC,EACD;EACCF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MACpE,MAAMC,UAAU,GACfH,UAAU,KAAK,QAAQ,GACpBC,UAAU,GACV,IAAAG,aAAO,GACP;MACA,IAAAC,QAAE,EAAE,WAAY,CAAC,EACjBJ,UAAU,EACVF,SACA,CAAC;MAEL1B,6BAA6B,CAACmB,IAAI,CAAE;QACnCc,GAAG,EAAG,GAAGN,UAAY,IAAIE,WAAa,EAAC;QACvCrC,IAAI,EAAEsC,UAAU;QAChBL,KAAK,EAAE;UACNJ,SAAS,EAAEM,UAAU;UACrBrB,UAAU,EAAEuB;QACb;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,OAAO;IACN/B,UAAU;IACVC,WAAW;IACXC,6BAA6B;IAC7BC,YAAY;IACZE;EACD,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_formatFontStyle","_formatFontWeight","FONT_STYLES","name","_x","value","FONT_WEIGHTS","getFontStylesAndWeights","fontFamilyFaces","fontStyles","fontWeights","combinedStyleAndWeightOptions","isSystemFont","length","isVariableFont","forEach","face","fontWeight","test","trim","startValue","endValue","split","parseInt","slice","i","fontWeightValue","toString","some","weight","push","formatFontWeight","fontStyle","formatFontStyle","Object","keys","style","styleName","styleValue","weightName","weightValue","optionName","sprintf","key"],"sources":["@wordpress/block-editor/src/utils/get-font-styles-and-weights.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param {Array} fontFamilyFaces font family faces array\n * @return {Object} new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights( fontFamilyFaces ) {\n\tlet fontStyles = [];\n\tlet fontWeights = [];\n\tconst combinedStyleAndWeightOptions = [];\n\tconst isSystemFont = ! fontFamilyFaces || fontFamilyFaces?.length === 0;\n\tlet isVariableFont = false;\n\n\tfontFamilyFaces?.forEach( ( face ) => {\n\t\t// Check for variable font by looking for a space in the font weight value. e.g. \"100 900\"\n\t\tif (\n\t\t\t'string' === typeof face.fontWeight &&\n\t\t\t/\\s/.test( face.fontWeight.trim() )\n\t\t) {\n\t\t\tisVariableFont = true;\n\n\t\t\t// Find font weight start and end values.\n\t\t\tlet [ startValue, endValue ] = face.fontWeight.split( ' ' );\n\t\t\tstartValue = parseInt( startValue.slice( 0, 1 ) );\n\t\t\tif ( endValue === '1000' ) {\n\t\t\t\tendValue = 10;\n\t\t\t} else {\n\t\t\t\tendValue = parseInt( endValue.slice( 0, 1 ) );\n\t\t\t}\n\n\t\t\t// Create font weight options for available variable weights.\n\t\t\tfor ( let i = startValue; i <= endValue; i++ ) {\n\t\t\t\tconst fontWeightValue = `${ i.toString() }00`;\n\t\t\t\tif (\n\t\t\t\t\t! fontWeights.some(\n\t\t\t\t\t\t( weight ) => weight.value === fontWeightValue\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfontWeights.push( formatFontWeight( fontWeightValue ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Format font style and weight values.\n\t\tconst fontWeight = formatFontWeight(\n\t\t\t'number' === typeof face.fontWeight\n\t\t\t\t? face.fontWeight.toString()\n\t\t\t\t: face.fontWeight\n\t\t);\n\t\tconst fontStyle = formatFontStyle( face.fontStyle );\n\n\t\t// Create font style and font weight lists without duplicates.\n\t\tif ( fontStyle && Object.keys( fontStyle ).length ) {\n\t\t\tif (\n\t\t\t\t! fontStyles.some(\n\t\t\t\t\t( style ) => style.value === fontStyle.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfontStyles.push( fontStyle );\n\t\t\t}\n\t\t}\n\n\t\tif ( fontWeight && Object.keys( fontWeight ).length ) {\n\t\t\tif (\n\t\t\t\t! fontWeights.some(\n\t\t\t\t\t( weight ) => weight.value === fontWeight.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( ! isVariableFont ) {\n\t\t\t\t\tfontWeights.push( fontWeight );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// If there is no font weight of 600 or above, then include faux bold as an option.\n\tif ( ! fontWeights.some( ( weight ) => weight.value >= '600' ) ) {\n\t\tfontWeights.push( {\n\t\t\tname: _x( 'Bold', 'font weight' ),\n\t\t\tvalue: '700',\n\t\t} );\n\t}\n\n\t// If there is no italic font style, then include faux italic as an option.\n\tif ( ! fontStyles.some( ( style ) => style.value === 'italic' ) ) {\n\t\tfontStyles.push( {\n\t\t\tname: _x( 'Italic', 'font style' ),\n\t\t\tvalue: 'italic',\n\t\t} );\n\t}\n\n\t// Use default font styles and weights for system fonts.\n\tif ( isSystemFont ) {\n\t\tfontStyles = FONT_STYLES;\n\t\tfontWeights = FONT_WEIGHTS;\n\t}\n\n\t// Use default styles and weights if there are no available styles or weights from the provided font faces.\n\tfontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;\n\tfontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;\n\n\t// Generate combined font style and weight options for available fonts.\n\tfontStyles.forEach( ( { name: styleName, value: styleValue } ) => {\n\t\tfontWeights.forEach( ( { name: weightName, value: weightValue } ) => {\n\t\t\tconst optionName =\n\t\t\t\tstyleValue === 'normal'\n\t\t\t\t\t? weightName\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Font weight name. 2: Font style name. */\n\t\t\t\t\t\t\t_x( '%1$s %2$s', 'font' ),\n\t\t\t\t\t\t\tweightName,\n\t\t\t\t\t\t\tstyleName\n\t\t\t\t\t );\n\n\t\t\tcombinedStyleAndWeightOptions.push( {\n\t\t\t\tkey: `${ styleValue }-${ weightValue }`,\n\t\t\t\tname: optionName,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontStyle: styleValue,\n\t\t\t\t\tfontWeight: weightValue,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t} );\n\n\treturn {\n\t\tfontStyles,\n\t\tfontWeights,\n\t\tcombinedStyleAndWeightOptions,\n\t\tisSystemFont,\n\t\tisVariableFont,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,MAAMG,WAAW,GAAG,CACnB;EACCC,IAAI,EAAE,IAAAC,QAAE,EAAE,SAAS,EAAE,YAAa,CAAC;EACnCC,KAAK,EAAE;AACR,CAAC,EACD;EACCF,IAAI,EAAE,IAAAC,QAAE,EAAE,QAAQ,EAAE,YAAa,CAAC;EAClCC,KAAK,EAAE;AACR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K,CAAC,GAAGX,WAAW,GAAGO,UAAU;EAC/DC,WAAW,GAAGA,WAAW,CAACG,MAAM,KAAK,CAAC,GAAGP,YAAY,GAAGI,WAAW;;EAEnE;EACAD,UAAU,CAACM,OAAO,CAAE,CAAE;IAAEZ,IAAI,EAAEkC,SAAS;IAAEhC,KAAK,EAAEiC;EAAW,CAAC,KAAM;IACjE5B,WAAW,CAACK,OAAO,CAAE,CAAE;MAAEZ,IAAI,EAAEoC,UAAU;MAAElC,KAAK,EAAEmC;IAAY,CAAC,KAAM;MACpE,MAAMC,UAAU,GACfH,UAAU,KAAK,QAAQ,GACpBC,UAAU,GACV,IAAAG,aAAO,EACP;MACA,IAAAtC,QAAE,EAAE,WAAW,EAAE,MAAO,CAAC,EACzBmC,UAAU,EACVF,SACA,CAAC;MAEL1B,6BAA6B,CAACmB,IAAI,CAAE;QACnCa,GAAG,EAAE,GAAIL,UAAU,IAAME,WAAW,EAAG;QACvCrC,IAAI,EAAEsC,UAAU;QAChBL,KAAK,EAAE;UACNJ,SAAS,EAAEM,UAAU;UACrBrB,UAAU,EAAEuB;QACb;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,OAAO;IACN/B,UAAU;IACVC,WAAW;IACXC,6BAA6B;IAC7BC,YAAY;IACZE;EACD,CAAC;AACF","ignoreList":[]}
|
package/build/utils/object.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setImmutably","object","path","value","Array","isArray","leaf","pop","prev","key","lvl","getValueFromObjectPath","defaultValue","_value","arrayPath","split","forEach","fieldName","exports","uniqByProperty","array","property","seen","Set","filter","item","has","add"],"sources":["@wordpress/block-editor/src/utils/object.js"],"sourcesContent":["/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\t// Normalize path\n\tpath = Array.isArray( path ) ? [ ...path ] : [ path ];\n\n\t// Shallowly clone the base of the object\n\tobject = Array.isArray( object ) ? [ ...object ] : { ...object };\n\n\tconst leaf = path.pop();\n\n\t// Traverse object from root to leaf, shallowly cloning at each level\n\tlet prev = object;\n\tfor ( const key of path ) {\n\t\tconst lvl = prev[ key ];\n\t\tprev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };\n\t}\n\n\tprev[ leaf ] = value;\n\n\treturn object;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst arrayPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tarrayPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n\n/**\n * Helper util to filter out objects with duplicate values for a given property.\n *\n * @param {Object[]} array Array of objects to filter.\n * @param {string} property Property to filter unique values by.\n *\n * @return {Object[]} Array of objects with unique values for the specified property.\n */\nexport function uniqByProperty( array, property ) {\n\tconst seen = new Set();\n\treturn array.filter( ( item ) => {\n\t\tconst value = item[ property ];\n\t\treturn seen.has( value ) ? false : seen.add( value );\n\t} );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["setImmutably","object","path","value","Array","isArray","leaf","pop","prev","key","lvl","getValueFromObjectPath","defaultValue","_value","arrayPath","split","forEach","fieldName","exports","uniqByProperty","array","property","seen","Set","filter","item","has","add"],"sources":["@wordpress/block-editor/src/utils/object.js"],"sourcesContent":["/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\t// Normalize path\n\tpath = Array.isArray( path ) ? [ ...path ] : [ path ];\n\n\t// Shallowly clone the base of the object\n\tobject = Array.isArray( object ) ? [ ...object ] : { ...object };\n\n\tconst leaf = path.pop();\n\n\t// Traverse object from root to leaf, shallowly cloning at each level\n\tlet prev = object;\n\tfor ( const key of path ) {\n\t\tconst lvl = prev[ key ];\n\t\tprev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };\n\t}\n\n\tprev[ leaf ] = value;\n\n\treturn object;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst arrayPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tarrayPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n\n/**\n * Helper util to filter out objects with duplicate values for a given property.\n *\n * @param {Object[]} array Array of objects to filter.\n * @param {string} property Property to filter unique values by.\n *\n * @return {Object[]} Array of objects with unique values for the specified property.\n */\nexport function uniqByProperty( array, property ) {\n\tconst seen = new Set();\n\treturn array.filter( ( item ) => {\n\t\tconst value = item[ property ];\n\t\treturn seen.has( value ) ? false : seen.add( value );\n\t} );\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA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A,cAAAA,MAAA,GAAID,YAAY;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAM,OAAA,CAAAP,sBAAA,GAAAA,sBAAA;AAQO,SAASQ,cAAcA,CAAEC,KAAK,EAAEC,QAAQ,EAAG;EACjD,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAC,CAAC;EACtB,OAAOH,KAAK,CAACI,MAAM,CAAIC,IAAI,IAAM;IAChC,MAAMtB,KAAK,GAAGsB,IAAI,CAAEJ,QAAQ,CAAE;IAC9B,OAAOC,IAAI,CAACI,GAAG,CAAEvB,KAAM,CAAC,GAAG,KAAK,GAAGmB,IAAI,CAACK,GAAG,CAAExB,KAAM,CAAC;EACrD,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dom","require","removeWindowsFragments","html","startStr","startIdx","indexOf","substring","length","endStr","endIdx","removeCharsetMetaTag","metaTag","startsWith","slice","getPasteEventData","clipboardData","plainText","getData","error","files","getFilesFromDataTransfer","shouldDismissPastedFiles","type","IMAGE_TAG","match","IMG_WITH_LOCAL_SRC"],"sources":["@wordpress/block-editor/src/utils/pasting.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceding and trailing content.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startStr = '<!--StartFragment-->';\n\tconst startIdx = html.indexOf( startStr );\n\tif ( startIdx > -1 ) {\n\t\thtml = html.substring( startIdx + startStr.length );\n\t} else {\n\t\t// No point looking for EndFragment\n\t\treturn html;\n\t}\n\n\tconst endStr = '<!--EndFragment-->';\n\tconst endIdx = html.indexOf( endStr );\n\tif ( endIdx > -1 ) {\n\t\thtml = html.substring( 0, endIdx );\n\t}\n\n\treturn html;\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n\nexport function getPasteEventData( { clipboardData } ) {\n\tlet plainText = '';\n\tlet html = '';\n\n\ttry {\n\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\thtml = clipboardData.getData( 'text/html' );\n\t} catch ( error ) {\n\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t// don't support clipboardData at all, so allow default\n\t\t// behaviour.\n\t\treturn;\n\t}\n\n\t// Remove Windows-specific metadata appended within copied HTML text.\n\thtml = removeWindowsFragments( html );\n\n\t// Strip meta tag.\n\thtml = removeCharsetMetaTag( html );\n\n\tconst files = getFilesFromDataTransfer( clipboardData );\n\n\tif ( files.length && ! shouldDismissPastedFiles( files, html ) ) {\n\t\treturn { files };\n\t}\n\n\treturn { html, plainText, files: [] };\n}\n\n/**\n * Given a collection of DataTransfer files and HTML and plain text strings,\n * determine whether the files are to be dismissed in favor of the HTML.\n *\n * Certain office-type programs, like Microsoft Word or Apple Numbers,\n * will, upon copy, generate a screenshot of the content being copied and\n * attach it to the clipboard alongside the actual rich text that the user\n * sought to copy. In those cases, we should let Gutenberg handle the rich text\n * content and not the screenshot, since this allows Gutenberg to insert\n * meaningful blocks, like paragraphs, lists or even tables.\n *\n * @param {File[]} files File objects obtained from a paste event\n * @param {string} html HTML content obtained from a paste event\n * @return {boolean} True if the files should be dismissed\n */\nexport function shouldDismissPastedFiles( files, html /*, plainText */ ) {\n\t// The question is only relevant when there is actual HTML content and when\n\t// there is exactly one image file.\n\tif (\n\t\thtml &&\n\t\tfiles?.length === 1 &&\n\t\tfiles[ 0 ].type.indexOf( 'image/' ) === 0\n\t) {\n\t\t// A single <img> tag found in the HTML source suggests that the\n\t\t// content being pasted revolves around an image. Sometimes there are\n\t\t// other elements found, like <figure>, but we assume that the user's\n\t\t// intention is to paste the actual image file.\n\t\tconst IMAGE_TAG = /<\\s*img\\b/gi;\n\t\tif ( html.match( IMAGE_TAG )?.length !== 1 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Even when there is exactly one <img> tag in the HTML payload, we\n\t\t// choose to weed out local images, i.e. those whose source starts with\n\t\t// \"file://\". These payloads occur in specific configurations, such as\n\t\t// when copying an entire document from Microsoft Word, that contains\n\t\t// text and exactly one image, and pasting that content using Google\n\t\t// Chrome.\n\t\tconst IMG_WITH_LOCAL_SRC = /<\\s*img\\b[^>]*\\bsrc=\"file:\\/\\//i;\n\t\tif ( html.match( IMG_WITH_LOCAL_SRC ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,sBAAsBA,CAAEC,IAAI,EAAG;EACvC,MAAMC,QAAQ,GAAG,sBAAsB;EACvC,MAAMC,QAAQ,GAAGF,IAAI,CAACG,OAAO,CAAEF,QAAS,CAAC;EACzC,IAAKC,QAAQ,GAAG,CAAC,CAAC,EAAG;IACpBF,IAAI,GAAGA,IAAI,CAACI,SAAS,CAAEF,QAAQ,GAAGD,QAAQ,CAACI,MAAO,CAAC;EACpD,CAAC,MAAM;IACN;IACA,OAAOL,IAAI;EACZ;EAEA,MAAMM,MAAM,GAAG,oBAAoB;EACnC,MAAMC,MAAM,GAAGP,IAAI,CAACG,OAAO,CAAEG,MAAO,CAAC;EACrC,IAAKC,MAAM,GAAG,CAAC,CAAC,EAAG;IAClBP,IAAI,GAAGA,IAAI,CAACI,SAAS,CAAE,CAAC,EAAEG,MAAO,CAAC;EACnC;EAEA,OAAOP,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,oBAAoBA,CAAER,IAAI,EAAG;EACrC,MAAMS,OAAO,
|
|
1
|
+
{"version":3,"names":["_dom","require","removeWindowsFragments","html","startStr","startIdx","indexOf","substring","length","endStr","endIdx","removeCharsetMetaTag","metaTag","startsWith","slice","getPasteEventData","clipboardData","plainText","getData","error","files","getFilesFromDataTransfer","shouldDismissPastedFiles","type","IMAGE_TAG","match","IMG_WITH_LOCAL_SRC"],"sources":["@wordpress/block-editor/src/utils/pasting.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceding and trailing content.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startStr = '<!--StartFragment-->';\n\tconst startIdx = html.indexOf( startStr );\n\tif ( startIdx > -1 ) {\n\t\thtml = html.substring( startIdx + startStr.length );\n\t} else {\n\t\t// No point looking for EndFragment\n\t\treturn html;\n\t}\n\n\tconst endStr = '<!--EndFragment-->';\n\tconst endIdx = html.indexOf( endStr );\n\tif ( endIdx > -1 ) {\n\t\thtml = html.substring( 0, endIdx );\n\t}\n\n\treturn html;\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n\nexport function getPasteEventData( { clipboardData } ) {\n\tlet plainText = '';\n\tlet html = '';\n\n\ttry {\n\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\thtml = clipboardData.getData( 'text/html' );\n\t} catch ( error ) {\n\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t// don't support clipboardData at all, so allow default\n\t\t// behaviour.\n\t\treturn;\n\t}\n\n\t// Remove Windows-specific metadata appended within copied HTML text.\n\thtml = removeWindowsFragments( html );\n\n\t// Strip meta tag.\n\thtml = removeCharsetMetaTag( html );\n\n\tconst files = getFilesFromDataTransfer( clipboardData );\n\n\tif ( files.length && ! shouldDismissPastedFiles( files, html ) ) {\n\t\treturn { files };\n\t}\n\n\treturn { html, plainText, files: [] };\n}\n\n/**\n * Given a collection of DataTransfer files and HTML and plain text strings,\n * determine whether the files are to be dismissed in favor of the HTML.\n *\n * Certain office-type programs, like Microsoft Word or Apple Numbers,\n * will, upon copy, generate a screenshot of the content being copied and\n * attach it to the clipboard alongside the actual rich text that the user\n * sought to copy. In those cases, we should let Gutenberg handle the rich text\n * content and not the screenshot, since this allows Gutenberg to insert\n * meaningful blocks, like paragraphs, lists or even tables.\n *\n * @param {File[]} files File objects obtained from a paste event\n * @param {string} html HTML content obtained from a paste event\n * @return {boolean} True if the files should be dismissed\n */\nexport function shouldDismissPastedFiles( files, html /*, plainText */ ) {\n\t// The question is only relevant when there is actual HTML content and when\n\t// there is exactly one image file.\n\tif (\n\t\thtml &&\n\t\tfiles?.length === 1 &&\n\t\tfiles[ 0 ].type.indexOf( 'image/' ) === 0\n\t) {\n\t\t// A single <img> tag found in the HTML source suggests that the\n\t\t// content being pasted revolves around an image. Sometimes there are\n\t\t// other elements found, like <figure>, but we assume that the user's\n\t\t// intention is to paste the actual image file.\n\t\tconst IMAGE_TAG = /<\\s*img\\b/gi;\n\t\tif ( html.match( IMAGE_TAG )?.length !== 1 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Even when there is exactly one <img> tag in the HTML payload, we\n\t\t// choose to weed out local images, i.e. those whose source starts with\n\t\t// \"file://\". These payloads occur in specific configurations, such as\n\t\t// when copying an entire document from Microsoft Word, that contains\n\t\t// text and exactly one image, and pasting that content using Google\n\t\t// Chrome.\n\t\tconst IMG_WITH_LOCAL_SRC = /<\\s*img\\b[^>]*\\bsrc=\"file:\\/\\//i;\n\t\tif ( html.match( IMG_WITH_LOCAL_SRC ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,sBAAsBA,CAAEC,IAAI,EAAG;EACvC,MAAMC,QAAQ,GAAG,sBAAsB;EACvC,MAAMC,QAAQ,GAAGF,IAAI,CAACG,OAAO,CAAEF,QAAS,CAAC;EACzC,IAAKC,QAAQ,GAAG,CAAC,CAAC,EAAG;IACpBF,IAAI,GAAGA,IAAI,CAACI,SAAS,CAAEF,QAAQ,GAAGD,QAAQ,CAACI,MAAO,CAAC;EACpD,CAAC,MAAM;IACN;IACA,OAAOL,IAAI;EACZ;EAEA,MAAMM,MAAM,GAAG,oBAAoB;EACnC,MAAMC,MAAM,GAAGP,IAAI,CAACG,OAAO,CAAEG,MAAO,CAAC;EACrC,IAAKC,MAAM,GAAG,CAAC,CAAC,EAAG;IAClBP,IAAI,GAAGA,IAAI,CAACI,SAAS,CAAE,CAAC,EAAEG,MAAO,CAAC;EACnC;EAEA,OAAOP,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,oBAAoBA,CAAER,IAAI,EAAG;EACrC,MAAMS,OAAO,GAAG,wBAAwB;EAExC,IAAKT,IAAI,CAACU,UAAU,CAAED,OAAQ,CAAC,EAAG;IACjC,OAAOT,IAAI,CAACW,KAAK,CAAEF,OAAO,CAACJ,MAAO,CAAC;EACpC;EAEA,OAAOL,IAAI;AACZ;AAEO,SAASY,iBAAiBA,CAAE;EAAEC;AAAc,CAAC,EAAG;EACtD,IAAIC,SAAS,GAAG,EAAE;EAClB,IA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ignoreList":[]}
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var parsel = _interopRequireWildcard(require("parsel-js"));
|
|
9
|
-
var
|
|
9
|
+
var _processor = _interopRequireDefault(require("postcss/lib/processor"));
|
|
10
|
+
var _cssSyntaxError = _interopRequireDefault(require("postcss/lib/css-syntax-error"));
|
|
10
11
|
var _postcssPrefixSelector = _interopRequireDefault(require("postcss-prefix-selector"));
|
|
11
12
|
var _postcssUrlrebase = _interopRequireDefault(require("postcss-urlrebase"));
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -108,7 +109,7 @@ function transformStyle({
|
|
|
108
109
|
try {
|
|
109
110
|
var _transformOptions$ign;
|
|
110
111
|
const excludedSelectors = [...ignoredSelectors, ...((_transformOptions$ign = transformOptions?.ignoredSelectors) !== null && _transformOptions$ign !== void 0 ? _transformOptions$ign : []), wrapperSelector];
|
|
111
|
-
return
|
|
112
|
+
return new _processor.default([wrapperSelector && (0, _postcssPrefixSelector.default)({
|
|
112
113
|
prefix: wrapperSelector,
|
|
113
114
|
transform(prefix, selector, prefixedSelector) {
|
|
114
115
|
// For backwards compatibility, don't use the `exclude` option
|
|
@@ -131,7 +132,7 @@ function transformStyle({
|
|
|
131
132
|
rootUrl: baseURL
|
|
132
133
|
})].filter(Boolean)).process(css, {}).css; // use sync PostCSS API
|
|
133
134
|
} catch (error) {
|
|
134
|
-
if (error instanceof
|
|
135
|
+
if (error instanceof _cssSyntaxError.default) {
|
|
135
136
|
// eslint-disable-next-line no-console
|
|
136
137
|
console.warn('wp.blockEditor.transformStyles Failed to transform CSS.', error.message + '\n' + error.showSourceCode(false));
|
|
137
138
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["parsel","_interopRequireWildcard","require","_postcss","_postcssPrefixSelector","_interopRequireDefault","_postcssUrlrebase","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","cacheByWrapperSelector","Map","ROOT_SELECTOR_TOKENS","type","content","prefixRootSelector","prefix","selector","tokenized","tokenize","lastRootIndex","findLastIndex","some","rootSelector","insertionPoint","length","tokenizedPrefix","splice","stringify","transformStyle","css","ignoredSelectors","baseURL","wrapperSelector","transformOptions","_transformOptions$ign","excludedSelectors","postcss","prefixSelector","transform","prefixedSelector","excludedSelector","RegExp","match","includes","hasRootSelector","startsWith","rebaseUrl","rootUrl","filter","Boolean","process","error","CssSyntaxError","console","warn","message","showSourceCode","transformStyles","styles","cache","map","style","_default","exports"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as parsel from 'parsel-js';\nimport postcss, { CssSyntaxError } from 'postcss';\nimport prefixSelector from 'postcss-prefix-selector';\nimport rebaseUrl from 'postcss-urlrebase';\n\nconst cacheByWrapperSelector = new Map();\n\nconst ROOT_SELECTOR_TOKENS = [\n\t{ type: 'type', content: 'body' },\n\t{ type: 'type', content: 'html' },\n\t{ type: 'pseudo-class', content: ':root' },\n\t{ type: 'pseudo-class', content: ':where(body)' },\n\t{ type: 'pseudo-class', content: ':where(:root)' },\n\t{ type: 'pseudo-class', content: ':where(html)' },\n];\n\n/**\n * Prefixes root selectors in a way that ensures consistent specificity.\n * This requires special handling, since prefixing a classname before\n * html, body, or :root will generally result in an invalid selector.\n *\n * Some libraries will simply replace the root selector with the prefix\n * instead, but this results in inconsistent specificity.\n *\n * This function instead inserts the prefix after the root tags but before\n * any other part of the selector. This results in consistent specificity:\n * - If a `:where()` selector is used for the prefix, all selectors output\n * by `transformStyles` will have no specificity increase.\n * - If a classname, id, or something else is used as the prefix, all selectors\n * will have the same specificity bump when transformed.\n *\n * @param {string} prefix The prefix.\n * @param {string} selector The selector.\n *\n * @return {string} The prefixed root selector.\n */\nfunction prefixRootSelector( prefix, selector ) {\n\t// Use a tokenizer, since regular expressions are unreliable.\n\tconst tokenized = parsel.tokenize( selector );\n\n\t// Find the last token that contains a root selector by walking back\n\t// through the tokens.\n\tconst lastRootIndex = tokenized.findLastIndex( ( { content, type } ) => {\n\t\treturn ROOT_SELECTOR_TOKENS.some(\n\t\t\t( rootSelector ) =>\n\t\t\t\tcontent === rootSelector.content && type === rootSelector.type\n\t\t);\n\t} );\n\n\t// Walk forwards to find the combinator after the last root.\n\t// This is where the root ends and the rest of the selector begins,\n\t// and the index to insert before.\n\t// Doing it this way takes into account that a root selector like\n\t// 'body' may have additional id/class/pseudo-class/attribute-selector\n\t// parts chained to it, which is difficult to quantify using a regex.\n\tlet insertionPoint = -1;\n\tfor ( let i = lastRootIndex + 1; i < tokenized.length; i++ ) {\n\t\tif ( tokenized[ i ].type === 'combinator' ) {\n\t\t\tinsertionPoint = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Tokenize and insert the prefix with a ' ' combinator before it.\n\tconst tokenizedPrefix = parsel.tokenize( prefix );\n\ttokenized.splice(\n\t\t// Insert at the insertion point, or the end.\n\t\tinsertionPoint === -1 ? tokenized.length : insertionPoint,\n\t\t0,\n\t\t{\n\t\t\ttype: 'combinator',\n\t\t\tcontent: ' ',\n\t\t},\n\t\t...tokenizedPrefix\n\t);\n\n\treturn parsel.stringify( tokenized );\n}\n\nfunction transformStyle(\n\t{ css, ignoredSelectors = [], baseURL },\n\twrapperSelector = '',\n\ttransformOptions\n) {\n\t// When there is no wrapper selector and no base URL, there is no need\n\t// to transform the CSS. This is most cases because in the default\n\t// iframed editor, no wrapping is needed, and not many styles\n\t// provide a base URL.\n\tif ( ! wrapperSelector && ! baseURL ) {\n\t\treturn css;\n\t}\n\n\ttry {\n\t\tconst excludedSelectors = [\n\t\t\t...ignoredSelectors,\n\t\t\t...( transformOptions?.ignoredSelectors ?? [] ),\n\t\t\twrapperSelector,\n\t\t];\n\n\t\treturn postcss(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\tprefixSelector( {\n\t\t\t\t\t\tprefix: wrapperSelector,\n\t\t\t\t\t\ttransform( prefix, selector, prefixedSelector ) {\n\t\t\t\t\t\t\t// For backwards compatibility, don't use the `exclude` option\n\t\t\t\t\t\t\t// of postcss-prefix-selector, instead handle it here to match\n\t\t\t\t\t\t\t// the behavior of the old library (postcss-prefix-wrap) that\n\t\t\t\t\t\t\t// `transformStyle` previously used.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\texcludedSelectors.some( ( excludedSelector ) =>\n\t\t\t\t\t\t\t\t\texcludedSelector instanceof RegExp\n\t\t\t\t\t\t\t\t\t\t? selector.match( excludedSelector )\n\t\t\t\t\t\t\t\t\t\t: selector.includes( excludedSelector )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn selector;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst hasRootSelector = ROOT_SELECTOR_TOKENS.some(\n\t\t\t\t\t\t\t\t( rootSelector ) =>\n\t\t\t\t\t\t\t\t\tselector.startsWith( rootSelector.content )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Reorganize root selectors such that the root part comes before the prefix,\n\t\t\t\t\t\t\t// but the prefix still comes before the remaining part of the selector.\n\t\t\t\t\t\t\tif ( hasRootSelector ) {\n\t\t\t\t\t\t\t\treturn prefixRootSelector( prefix, selector );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn prefixedSelector;\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean )\n\t\t).process( css, {} ).css; // use sync PostCSS API\n\t} catch ( error ) {\n\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t);\n\t\t} else {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n */\n\n/**\n * @typedef {Object} TransformOptions\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n */\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @param {TransformOptions} transformOptions Additional options for style transformation.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '', transformOptions ) => {\n\tlet cache = cacheByWrapperSelector.get( wrapperSelector );\n\tif ( ! cache ) {\n\t\tcache = new WeakMap();\n\t\tcacheByWrapperSelector.set( wrapperSelector, cache );\n\t}\n\treturn styles.map( ( style ) => {\n\t\tlet css = cache.get( style );\n\t\tif ( ! css ) {\n\t\t\tcss = transformStyle( style, wrapperSelector, transformOptions );\n\t\t\tcache.set( style, css );\n\t\t}\n\t\treturn css;\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAA0C,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAA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EACX,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAApE,OAAA,GAEa8D,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["parsel","_interopRequireWildcard","require","_processor","_interopRequireDefault","_cssSyntaxError","_postcssPrefixSelector","_postcssUrlrebase","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","cacheByWrapperSelector","Map","ROOT_SELECTOR_TOKENS","type","content","prefixRootSelector","prefix","selector","tokenized","tokenize","lastRootIndex","findLastIndex","some","rootSelector","insertionPoint","length","tokenizedPrefix","splice","stringify","transformStyle","css","ignoredSelectors","baseURL","wrapperSelector","transformOptions","_transformOptions$ign","excludedSelectors","Processor","prefixSelector","transform","prefixedSelector","excludedSelector","RegExp","match","includes","hasRootSelector","startsWith","rebaseUrl","rootUrl","filter","Boolean","process","error","CssSyntaxError","console","warn","message","showSourceCode","transformStyles","styles","cache","map","style","_default","exports"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as parsel from 'parsel-js';\nimport Processor from 'postcss/lib/processor';\nimport CssSyntaxError from 'postcss/lib/css-syntax-error';\nimport prefixSelector from 'postcss-prefix-selector';\nimport rebaseUrl from 'postcss-urlrebase';\n\nconst cacheByWrapperSelector = new Map();\n\nconst ROOT_SELECTOR_TOKENS = [\n\t{ type: 'type', content: 'body' },\n\t{ type: 'type', content: 'html' },\n\t{ type: 'pseudo-class', content: ':root' },\n\t{ type: 'pseudo-class', content: ':where(body)' },\n\t{ type: 'pseudo-class', content: ':where(:root)' },\n\t{ type: 'pseudo-class', content: ':where(html)' },\n];\n\n/**\n * Prefixes root selectors in a way that ensures consistent specificity.\n * This requires special handling, since prefixing a classname before\n * html, body, or :root will generally result in an invalid selector.\n *\n * Some libraries will simply replace the root selector with the prefix\n * instead, but this results in inconsistent specificity.\n *\n * This function instead inserts the prefix after the root tags but before\n * any other part of the selector. This results in consistent specificity:\n * - If a `:where()` selector is used for the prefix, all selectors output\n * by `transformStyles` will have no specificity increase.\n * - If a classname, id, or something else is used as the prefix, all selectors\n * will have the same specificity bump when transformed.\n *\n * @param {string} prefix The prefix.\n * @param {string} selector The selector.\n *\n * @return {string} The prefixed root selector.\n */\nfunction prefixRootSelector( prefix, selector ) {\n\t// Use a tokenizer, since regular expressions are unreliable.\n\tconst tokenized = parsel.tokenize( selector );\n\n\t// Find the last token that contains a root selector by walking back\n\t// through the tokens.\n\tconst lastRootIndex = tokenized.findLastIndex( ( { content, type } ) => {\n\t\treturn ROOT_SELECTOR_TOKENS.some(\n\t\t\t( rootSelector ) =>\n\t\t\t\tcontent === rootSelector.content && type === rootSelector.type\n\t\t);\n\t} );\n\n\t// Walk forwards to find the combinator after the last root.\n\t// This is where the root ends and the rest of the selector begins,\n\t// and the index to insert before.\n\t// Doing it this way takes into account that a root selector like\n\t// 'body' may have additional id/class/pseudo-class/attribute-selector\n\t// parts chained to it, which is difficult to quantify using a regex.\n\tlet insertionPoint = -1;\n\tfor ( let i = lastRootIndex + 1; i < tokenized.length; i++ ) {\n\t\tif ( tokenized[ i ].type === 'combinator' ) {\n\t\t\tinsertionPoint = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Tokenize and insert the prefix with a ' ' combinator before it.\n\tconst tokenizedPrefix = parsel.tokenize( prefix );\n\ttokenized.splice(\n\t\t// Insert at the insertion point, or the end.\n\t\tinsertionPoint === -1 ? tokenized.length : insertionPoint,\n\t\t0,\n\t\t{\n\t\t\ttype: 'combinator',\n\t\t\tcontent: ' ',\n\t\t},\n\t\t...tokenizedPrefix\n\t);\n\n\treturn parsel.stringify( tokenized );\n}\n\nfunction transformStyle(\n\t{ css, ignoredSelectors = [], baseURL },\n\twrapperSelector = '',\n\ttransformOptions\n) {\n\t// When there is no wrapper selector and no base URL, there is no need\n\t// to transform the CSS. This is most cases because in the default\n\t// iframed editor, no wrapping is needed, and not many styles\n\t// provide a base URL.\n\tif ( ! wrapperSelector && ! baseURL ) {\n\t\treturn css;\n\t}\n\n\ttry {\n\t\tconst excludedSelectors = [\n\t\t\t...ignoredSelectors,\n\t\t\t...( transformOptions?.ignoredSelectors ?? [] ),\n\t\t\twrapperSelector,\n\t\t];\n\n\t\treturn new Processor(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\tprefixSelector( {\n\t\t\t\t\t\tprefix: wrapperSelector,\n\t\t\t\t\t\ttransform( prefix, selector, prefixedSelector ) {\n\t\t\t\t\t\t\t// For backwards compatibility, don't use the `exclude` option\n\t\t\t\t\t\t\t// of postcss-prefix-selector, instead handle it here to match\n\t\t\t\t\t\t\t// the behavior of the old library (postcss-prefix-wrap) that\n\t\t\t\t\t\t\t// `transformStyle` previously used.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\texcludedSelectors.some( ( excludedSelector ) =>\n\t\t\t\t\t\t\t\t\texcludedSelector instanceof RegExp\n\t\t\t\t\t\t\t\t\t\t? selector.match( excludedSelector )\n\t\t\t\t\t\t\t\t\t\t: selector.includes( excludedSelector )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn selector;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst hasRootSelector = ROOT_SELECTOR_TOKENS.some(\n\t\t\t\t\t\t\t\t( rootSelector ) =>\n\t\t\t\t\t\t\t\t\tselector.startsWith( rootSelector.content )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Reorganize root selectors such that the root part comes before the prefix,\n\t\t\t\t\t\t\t// but the prefix still comes before the remaining part of the selector.\n\t\t\t\t\t\t\tif ( hasRootSelector ) {\n\t\t\t\t\t\t\t\treturn prefixRootSelector( prefix, selector );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn prefixedSelector;\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean )\n\t\t).process( css, {} ).css; // use sync PostCSS API\n\t} catch ( error ) {\n\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t);\n\t\t} else {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n */\n\n/**\n * @typedef {Object} TransformOptions\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n */\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @param {TransformOptions} transformOptions Additional options for style transformation.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '', transformOptions ) => {\n\tlet cache = cacheByWrapperSelector.get( wrapperSelector );\n\tif ( ! cache ) {\n\t\tcache = new WeakMap();\n\t\tcacheByWrapperSelector.set( wrapperSelector, cache );\n\t}\n\treturn styles.map( ( style ) => {\n\t\tlet css = cache.get( style );\n\t\tif ( ! css ) {\n\t\t\tcss = transformStyle( style, wrapperSelector, transformOptions );\n\t\t\tcache.set( style, css );\n\t\t}\n\t\treturn css;\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA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,GAAG,CAAEgE,KAAM,CAAC;IAC5B,IAAK,CAAEhC,GAAG,EAAG;MACZA,GAAG,GAAGD,cAAc,CAAEiC,KAAK,EAAE7B,eAAe,EAAEC,gBAAiB,CAAC;MAChE0B,KAAK,CAACnD,GAAG,CAAEqD,KAAK,EAAEhC,GAAI,CAAC;IACxB;IACA,OAAOA,GAAG;EACX,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAApE,OAAA,GAEa8D,eAAe","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { createBlock, createBlocksFromInnerBlocksTemplate, parse } from '@wordpress/blocks';
|
|
5
|
+
import { createBlock, createBlocksFromInnerBlocksTemplate, parse, store as blocksStore } from '@wordpress/blocks';
|
|
6
6
|
import { useMemo } from '@wordpress/element';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -14,9 +14,7 @@ import BlockIcon from '../components/block-icon';
|
|
|
14
14
|
import { store as blockEditorStore } from '../store';
|
|
15
15
|
import { orderBy } from '../utils/sorting';
|
|
16
16
|
import { orderInserterBlockItems } from '../utils/order-inserter-block-items';
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
18
|
const noop = () => {};
|
|
21
19
|
const SHOWN_BLOCK_TYPES = 9;
|
|
22
20
|
|
|
@@ -35,19 +33,27 @@ function createBlockCompleter() {
|
|
|
35
33
|
useItems(filterValue) {
|
|
36
34
|
const {
|
|
37
35
|
rootClientId,
|
|
38
|
-
|
|
36
|
+
selectedBlockId,
|
|
39
37
|
prioritizedBlocks
|
|
40
38
|
} = useSelect(select => {
|
|
41
39
|
const {
|
|
42
40
|
getSelectedBlockClientId,
|
|
43
|
-
|
|
41
|
+
getBlock,
|
|
44
42
|
getBlockListSettings,
|
|
45
43
|
getBlockRootClientId
|
|
46
44
|
} = select(blockEditorStore);
|
|
45
|
+
const {
|
|
46
|
+
getActiveBlockVariation
|
|
47
|
+
} = select(blocksStore);
|
|
47
48
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
49
|
+
const {
|
|
50
|
+
name: blockName,
|
|
51
|
+
attributes
|
|
52
|
+
} = getBlock(selectedBlockClientId);
|
|
53
|
+
const activeBlockVariation = getActiveBlockVariation(blockName, attributes);
|
|
48
54
|
const _rootClientId = getBlockRootClientId(selectedBlockClientId);
|
|
49
55
|
return {
|
|
50
|
-
|
|
56
|
+
selectedBlockId: activeBlockVariation ? `${blockName}/${activeBlockVariation.name}` : blockName,
|
|
51
57
|
rootClientId: _rootClientId,
|
|
52
58
|
prioritizedBlocks: getBlockListSettings(_rootClientId)?.prioritizedInserterBlocks
|
|
53
59
|
};
|
|
@@ -55,8 +61,8 @@ function createBlockCompleter() {
|
|
|
55
61
|
const [items, categories, collections] = useBlockTypesState(rootClientId, noop, true);
|
|
56
62
|
const filteredItems = useMemo(() => {
|
|
57
63
|
const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : orderInserterBlockItems(orderBy(items, 'frecency', 'desc'), prioritizedBlocks);
|
|
58
|
-
return initialFilteredItems.filter(item => item.
|
|
59
|
-
}, [filterValue,
|
|
64
|
+
return initialFilteredItems.filter(item => item.id !== selectedBlockId).slice(0, SHOWN_BLOCK_TYPES);
|
|
65
|
+
}, [filterValue, selectedBlockId, items, categories, collections, prioritizedBlocks]);
|
|
60
66
|
const options = useMemo(() => filteredItems.map(blockItem => {
|
|
61
67
|
const {
|
|
62
68
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","parse","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","
|
|
1
|
+
{"version":3,"names":["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","parse","store","blocksStore","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","blockEditorStore","orderBy","orderInserterBlockItems","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockId","prioritizedBlocks","select","getSelectedBlockClientId","getBlock","getBlockListSettings","getBlockRootClientId","getActiveBlockVariation","selectedBlockClientId","blockName","attributes","activeBlockVariation","_rootClientId","prioritizedInserterBlocks","items","categories","collections","filteredItems","initialFilteredItems","trim","filter","item","id","slice","options","map","blockItem","title","icon","isDisabled","key","value","label","children","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","__unstableSkipMigrationLogs"],"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tparse,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchBlockItems } from '../components/inserter/search-items';\nimport useBlockTypesState from '../components/inserter/hooks/use-block-types-state';\nimport BlockIcon from '../components/block-icon';\nimport { store as blockEditorStore } from '../store';\nimport { orderBy } from '../utils/sorting';\nimport { orderInserterBlockItems } from '../utils/order-inserter-block-items';\n\nconst noop = () => {};\nconst SHOWN_BLOCK_TYPES = 9;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nfunction createBlockCompleter() {\n\treturn {\n\t\tname: 'blocks',\n\t\tclassName: 'block-editor-autocompleters__block',\n\t\ttriggerPrefix: '/',\n\n\t\tuseItems( filterValue ) {\n\t\t\tconst { rootClientId, selectedBlockId, prioritizedBlocks } =\n\t\t\t\tuseSelect( ( select ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\t\tgetBlock,\n\t\t\t\t\t\tgetBlockListSettings,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\t\t\t\t\tconst { getActiveBlockVariation } = select( blocksStore );\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\t\tconst { name: blockName, attributes } = getBlock(\n\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst activeBlockVariation = getActiveBlockVariation(\n\t\t\t\t\t\tblockName,\n\t\t\t\t\t\tattributes\n\t\t\t\t\t);\n\t\t\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tselectedBlockId: activeBlockVariation\n\t\t\t\t\t\t\t? `${ blockName }/${ activeBlockVariation.name }`\n\t\t\t\t\t\t\t: blockName,\n\t\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\t\tprioritizedBlocks:\n\t\t\t\t\t\t\tgetBlockListSettings( _rootClientId )\n\t\t\t\t\t\t\t\t?.prioritizedInserterBlocks,\n\t\t\t\t\t};\n\t\t\t\t}, [] );\n\t\t\tconst [ items, categories, collections ] = useBlockTypesState(\n\t\t\t\trootClientId,\n\t\t\t\tnoop,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tconst filteredItems = useMemo( () => {\n\t\t\t\tconst initialFilteredItems = !! filterValue.trim()\n\t\t\t\t\t? searchBlockItems(\n\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\tcategories,\n\t\t\t\t\t\t\tcollections,\n\t\t\t\t\t\t\tfilterValue\n\t\t\t\t\t )\n\t\t\t\t\t: orderInserterBlockItems(\n\t\t\t\t\t\t\torderBy( items, 'frecency', 'desc' ),\n\t\t\t\t\t\t\tprioritizedBlocks\n\t\t\t\t\t );\n\n\t\t\t\treturn initialFilteredItems\n\t\t\t\t\t.filter( ( item ) => item.id !== selectedBlockId )\n\t\t\t\t\t.slice( 0, SHOWN_BLOCK_TYPES );\n\t\t\t}, [\n\t\t\t\tfilterValue,\n\t\t\t\tselectedBlockId,\n\t\t\t\titems,\n\t\t\t\tcategories,\n\t\t\t\tcollections,\n\t\t\t\tprioritizedBlocks,\n\t\t\t] );\n\n\t\t\tconst options = useMemo(\n\t\t\t\t() =>\n\t\t\t\t\tfilteredItems.map( ( blockItem ) => {\n\t\t\t\t\t\tconst { title, icon, isDisabled } = blockItem;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tkey: `block-${ blockItem.id }`,\n\t\t\t\t\t\t\tvalue: blockItem,\n\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tisDisabled,\n\t\t\t\t\t\t};\n\t\t\t\t\t} ),\n\t\t\t\t[ filteredItems ]\n\t\t\t);\n\n\t\t\treturn [ options ];\n\t\t},\n\t\tallowContext( before, after ) {\n\t\t\treturn ! ( /\\S/.test( before ) || /\\S/.test( after ) );\n\t\t},\n\t\tgetOptionCompletion( inserterItem ) {\n\t\t\tconst {\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks,\n\t\t\t\tsyncStatus,\n\t\t\t\tcontent,\n\t\t\t} = inserterItem;\n\n\t\t\treturn {\n\t\t\t\taction: 'replace',\n\t\t\t\tvalue:\n\t\t\t\t\tsyncStatus === 'unsynced'\n\t\t\t\t\t\t? parse( content, {\n\t\t\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: createBlock(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tinitialAttributes,\n\t\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\t\tinnerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nexport default createBlockCompleter();\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,mCAAmC,EACnCC,KAAK,EACLC,KAAK,IAAIC,WAAW,QACd,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,kBAAkB,MAAM,oDAAoD;AACnF,OAAOC,SAAS,MAAM,0BAA0B;AAChD,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,uBAAuB,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9E,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,iBAAiB,GAAG,CAAC;;AAE3B;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAG;EAC/B,OAAO;IACNC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,oCAAoC;IAC/CC,aAAa,EAAE,GAAG;IAElBC,QAAQA,CAAEC,WAAW,EAAG;MACvB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ACD,CACA;MACL,CAAC;IACF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAejD,oBAAoB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -7,9 +7,7 @@ import apiFetch from '@wordpress/api-fetch';
|
|
|
7
7
|
import { addQueryArgs } from '@wordpress/url';
|
|
8
8
|
import { Icon, page, post } from '@wordpress/icons';
|
|
9
9
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
11
|
const SHOWN_SUGGESTIONS = 10;
|
|
14
12
|
|
|
15
13
|
/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["apiFetch","addQueryArgs","Icon","page","post","decodeEntities","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SHOWN_SUGGESTIONS","createLinkCompleter","name","className","triggerPrefix","options","letters","path","per_page","search","type","order_by","filter","option","title","getOptionKeywords","item","expansionWords","split","getOptionLabel","children","icon","subtype","getOptionCompletion","href","url"],"sources":["@wordpress/block-editor/src/autocompleters/link.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n// Disable Reason: Needs to be refactored.\n// eslint-disable-next-line no-restricted-imports\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Icon, page, post } from '@wordpress/icons';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst SHOWN_SUGGESTIONS = 10;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a suggestion list for links to posts or pages.\n *\n * @return {WPCompleter} A links completer.\n */\nfunction createLinkCompleter() {\n\treturn {\n\t\tname: 'links',\n\t\tclassName: 'block-editor-autocompleters__link',\n\t\ttriggerPrefix: '[[',\n\t\toptions: async ( letters ) => {\n\t\t\tlet options = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tper_page: SHOWN_SUGGESTIONS,\n\t\t\t\t\tsearch: letters,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\torder_by: 'menu_order',\n\t\t\t\t} ),\n\t\t\t} );\n\n\t\t\toptions = options.filter( ( option ) => option.title !== '' );\n\n\t\t\treturn options;\n\t\t},\n\t\tgetOptionKeywords( item ) {\n\t\t\tconst expansionWords = item.title.split( /\\s+/ );\n\t\t\treturn [ ...expansionWords ];\n\t\t},\n\t\tgetOptionLabel( item ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\ticon={ item.subtype === 'page' ? page : post }\n\t\t\t\t\t/>\n\t\t\t\t\t{ decodeEntities( item.title ) }\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t\tgetOptionCompletion( item ) {\n\t\t\treturn <a href={ item.url }>{ item.title }</a>;\n\t\t},\n\t};\n}\n\n/**\n * Creates a suggestion list for links to posts or pages..\n *\n * @return {WPCompleter} A link completer.\n */\nexport default createLinkCompleter();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,IAAI,EAAEC,IAAI,EAAEC,IAAI,QAAQ,kBAAkB;AACnD,SAASC,cAAc,QAAQ,0BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["apiFetch","addQueryArgs","Icon","page","post","decodeEntities","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SHOWN_SUGGESTIONS","createLinkCompleter","name","className","triggerPrefix","options","letters","path","per_page","search","type","order_by","filter","option","title","getOptionKeywords","item","expansionWords","split","getOptionLabel","children","icon","subtype","getOptionCompletion","href","url"],"sources":["@wordpress/block-editor/src/autocompleters/link.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n// Disable Reason: Needs to be refactored.\n// eslint-disable-next-line no-restricted-imports\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Icon, page, post } from '@wordpress/icons';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst SHOWN_SUGGESTIONS = 10;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a suggestion list for links to posts or pages.\n *\n * @return {WPCompleter} A links completer.\n */\nfunction createLinkCompleter() {\n\treturn {\n\t\tname: 'links',\n\t\tclassName: 'block-editor-autocompleters__link',\n\t\ttriggerPrefix: '[[',\n\t\toptions: async ( letters ) => {\n\t\t\tlet options = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tper_page: SHOWN_SUGGESTIONS,\n\t\t\t\t\tsearch: letters,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\torder_by: 'menu_order',\n\t\t\t\t} ),\n\t\t\t} );\n\n\t\t\toptions = options.filter( ( option ) => option.title !== '' );\n\n\t\t\treturn options;\n\t\t},\n\t\tgetOptionKeywords( item ) {\n\t\t\tconst expansionWords = item.title.split( /\\s+/ );\n\t\t\treturn [ ...expansionWords ];\n\t\t},\n\t\tgetOptionLabel( item ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\ticon={ item.subtype === 'page' ? page : post }\n\t\t\t\t\t/>\n\t\t\t\t\t{ decodeEntities( item.title ) }\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t\tgetOptionCompletion( item ) {\n\t\t\treturn <a href={ item.url }>{ item.title }</a>;\n\t\t},\n\t};\n}\n\n/**\n * Creates a suggestion list for links to posts or pages..\n *\n * @return {WPCompleter} A link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QAAM,GAD1C,MAEJ,CAAC,EACAC,cAAc,CAAEuB,IAAI,CAACF,KAAM,CAAC;MAAA,CAC7B,CAAC;IAEL,CAAC;IACDS,mBAAmBA,CAAEP,IAAI,EAAG;MAC3B,oBAAOrB,IAAA;QAAG6B,IAAI,EAAGR,IAAI,CAACS,GAAK;QAAAL,QAAA,EAAGJ,IAAI,CAACF;MAAK,CAAK,CAAC;IAC/C;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAeb,mBAAmB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -22,8 +22,7 @@ import { useState } from '@wordpress/element';
|
|
|
22
22
|
import styles from './styles.scss';
|
|
23
23
|
import { parseAudioUrl } from './audio-url-parser.native';
|
|
24
24
|
import { useEditorColorScheme } from '../global-styles/use-global-styles-context';
|
|
25
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
26
|
const isIOS = Platform.OS === 'ios';
|
|
28
27
|
function Player({
|
|
29
28
|
isUploadInProgress,
|