@wordpress/block-editor 14.6.0 → 14.7.1-next.082ed6819.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 +2 -0
- package/build/components/block-controls/slot.js +6 -3
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +14 -28
- package/build/components/block-list/block.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-manager/category.js +79 -0
- package/build/components/block-manager/category.js.map +1 -0
- package/build/components/block-manager/checklist.js +40 -0
- package/build/components/block-manager/checklist.js.map +1 -0
- package/build/components/block-manager/index.js +108 -0
- package/build/components/block-manager/index.js.map +1 -0
- package/build/components/block-patterns-list/index.js +23 -26
- package/build/components/block-patterns-list/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/async.js +51 -0
- package/build/components/block-preview/async.js.map +1 -0
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +1 -4
- package/build/components/block-toolbar/change-design.js.map +1 -1
- package/build/components/block-toolbar/index.js +7 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/switch-section-style.js +105 -0
- package/build/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build/components/block-tools/index.js +12 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/collab/block-comment-icon-slot.js +2 -6
- package/build/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +4 -2
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/font-family/index.js +14 -13
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +26 -14
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +4 -4
- package/build/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build/components/iframe/index.js +156 -23
- package/build/components/iframe/index.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/index.js +1 -2
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -6
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +5 -1
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +7 -8
- 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-paging.js +0 -5
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build/components/inserter/search-results.js +0 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +2 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +7 -4
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/media-placeholder/index.js +33 -25
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +1 -1
- package/build/components/tabbed-sidebar/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +5 -6
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/style.js +6 -6
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -7
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +6 -6
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +3 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +11 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +12 -8
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -4
- package/build/store/utils.js.map +1 -1
- package/build/utils/dom.js +27 -22
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/block-controls/slot.js +6 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +15 -27
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-manager/category.js +71 -0
- package/build-module/components/block-manager/category.js.map +1 -0
- package/build-module/components/block-manager/checklist.js +32 -0
- package/build-module/components/block-manager/checklist.js.map +1 -0
- package/build-module/components/block-manager/index.js +102 -0
- package/build-module/components/block-manager/index.js.map +1 -0
- package/build-module/components/block-patterns-list/index.js +23 -26
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/async.js +44 -0
- package/build-module/components/block-preview/async.js.map +1 -0
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +2 -2
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +1 -4
- package/build-module/components/block-toolbar/change-design.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/switch-section-style.js +97 -0
- package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build-module/components/block-tools/index.js +13 -10
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +4 -2
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/font-family/index.js +15 -14
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +26 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +4 -4
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build-module/components/iframe/index.js +157 -24
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- 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 -2
- 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 +5 -7
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +8 -9
- 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-paging.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build-module/components/inserter/search-results.js +0 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +2 -1
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +7 -4
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +33 -25
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +1 -1
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +4 -4
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/style.js +6 -6
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -7
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +6 -6
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +3 -3
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +11 -9
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +6 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +12 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -3
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/dom.js +25 -21
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/content-rtl.css +30 -15
- package/build-style/content.css +30 -15
- package/build-style/style-rtl.css +92 -3
- package/build-style/style.css +92 -3
- package/build-types/utils/dom.d.ts +7 -9
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/components/block-canvas/style.scss +1 -1
- package/src/components/block-controls/slot.js +5 -3
- package/src/components/block-inspector/index.js +0 -2
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-list/block.js +28 -48
- package/src/components/block-lock/modal.js +1 -1
- package/src/components/block-manager/category.js +102 -0
- package/src/components/block-manager/checklist.js +34 -0
- package/src/components/block-manager/index.js +127 -0
- package/src/components/block-manager/style.scss +82 -0
- package/src/components/block-mover/README.md +15 -8
- package/src/components/block-mover/stories/index.story.js +73 -71
- package/src/components/block-mover/style.scss +3 -0
- package/src/components/block-patterns-list/README.md +8 -8
- package/src/components/block-patterns-list/index.js +35 -51
- package/src/components/block-patterns-list/stories/index.story.js +2 -19
- package/src/components/block-popover/index.js +4 -4
- package/src/components/block-preview/async.js +43 -0
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-toolbar/change-design.js +1 -7
- package/src/components/block-toolbar/index.js +6 -0
- package/src/components/block-toolbar/switch-section-style.js +115 -0
- package/src/components/block-tools/index.js +26 -10
- package/src/components/block-tools/style.scss +12 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/src/components/block-tools/use-show-block-tools.js +3 -1
- package/src/components/collab/block-comment-icon-slot.js +2 -6
- package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
- package/src/components/color-palette/with-color-context.js +25 -7
- package/src/components/default-block-appender/content.scss +13 -19
- package/src/components/font-family/index.js +13 -13
- package/src/components/global-styles/dimensions-panel.js +22 -16
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +1 -1
- package/src/components/iframe/content.scss +16 -3
- package/src/components/iframe/get-compatibility-styles.js +4 -9
- package/src/components/iframe/index.js +204 -44
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
- package/src/components/inserter/block-patterns-tab/index.js +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -17
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
- package/src/components/inserter/block-patterns-tab/utils.js +5 -0
- package/src/components/inserter/category-tabs/index.js +8 -9
- package/src/components/inserter/hooks/use-block-types-state.js +6 -1
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/src/components/inserter/search-results.js +0 -6
- package/src/components/inserter-draggable-blocks/index.js +10 -1
- package/src/components/inspector-controls/README.md +2 -0
- package/src/components/inspector-controls/slot.js +6 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
- package/src/components/media-placeholder/index.js +41 -37
- package/src/components/provider/test/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +15 -10
- package/src/components/rich-text/index.js +8 -1
- package/src/components/tabbed-sidebar/index.js +1 -1
- package/src/components/tabbed-sidebar/style.scss +1 -1
- package/src/components/url-input/index.js +3 -4
- package/src/components/use-block-commands/index.js +245 -234
- package/src/hooks/border.js +3 -9
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/font-family.js +1 -1
- package/src/hooks/style.js +6 -12
- package/src/hooks/supports.js +7 -7
- package/src/hooks/test/style.js +1 -2
- package/src/hooks/typography.js +6 -6
- package/src/hooks/utils.js +8 -3
- package/src/layouts/flex.js +26 -18
- package/src/private-apis.js +6 -6
- package/src/store/private-selectors.js +6 -7
- package/src/store/selectors.js +60 -45
- package/src/store/test/private-selectors.js +5 -0
- package/src/store/test/selectors.js +87 -58
- package/src/store/utils.js +12 -11
- package/src/style.scss +1 -0
- package/src/utils/dom.js +26 -21
- package/src/utils/test/dom.js +224 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-info-slot-fill/index.js +0 -39
- package/build/components/block-info-slot-fill/index.js.map +0 -1
- package/build-module/components/block-info-slot-fill/index.js +0 -32
- package/build-module/components/block-info-slot-fill/index.js.map +0 -1
- package/src/components/block-info-slot-fill/index.js +0 -27
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useMergeRefs,
|
|
21
21
|
useRefEffect,
|
|
22
22
|
useDisabled,
|
|
23
|
+
useReducedMotion,
|
|
23
24
|
} from '@wordpress/compose';
|
|
24
25
|
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
|
|
25
26
|
import { useSelect } from '@wordpress/data';
|
|
@@ -121,6 +122,7 @@ function Iframe( {
|
|
|
121
122
|
};
|
|
122
123
|
}, [] );
|
|
123
124
|
const { styles = '', scripts = '' } = resolvedAssets;
|
|
125
|
+
/** @type {[Document, import('react').Dispatch<Document>]} */
|
|
124
126
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
125
127
|
const initialContainerWidthRef = useRef( 0 );
|
|
126
128
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
@@ -130,6 +132,7 @@ function Iframe( {
|
|
|
130
132
|
useResizeObserver();
|
|
131
133
|
const [ containerResizeListener, { width: containerWidth } ] =
|
|
132
134
|
useResizeObserver();
|
|
135
|
+
const prefersReducedMotion = useReducedMotion();
|
|
133
136
|
|
|
134
137
|
const setRef = useRefEffect( ( node ) => {
|
|
135
138
|
node._load = () => {
|
|
@@ -191,6 +194,22 @@ function Iframe( {
|
|
|
191
194
|
preventFileDropDefault,
|
|
192
195
|
false
|
|
193
196
|
);
|
|
197
|
+
// Prevent clicks on links from navigating away. Note that links
|
|
198
|
+
// inside `contenteditable` are already disabled by the browser, so
|
|
199
|
+
// this is for links in blocks outside of `contenteditable`.
|
|
200
|
+
iFrameDocument.addEventListener( 'click', ( event ) => {
|
|
201
|
+
if ( event.target.tagName === 'A' ) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
|
|
204
|
+
// Appending a hash to the current URL will not reload the
|
|
205
|
+
// page. This is useful for e.g. footnotes.
|
|
206
|
+
const href = event.target.getAttribute( 'href' );
|
|
207
|
+
if ( href.startsWith( '#' ) ) {
|
|
208
|
+
iFrameDocument.defaultView.location.hash =
|
|
209
|
+
href.slice( 1 );
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} );
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
node.addEventListener( 'load', onLoad );
|
|
@@ -252,6 +271,19 @@ function Iframe( {
|
|
|
252
271
|
containerWidth
|
|
253
272
|
);
|
|
254
273
|
|
|
274
|
+
const frameSizeValue = parseInt( frameSize );
|
|
275
|
+
|
|
276
|
+
const maxWidth = 750;
|
|
277
|
+
const scaleValue =
|
|
278
|
+
scale === 'auto-scaled'
|
|
279
|
+
? ( Math.min( containerWidth, maxWidth ) - frameSizeValue * 2 ) /
|
|
280
|
+
scaleContainerWidth
|
|
281
|
+
: scale;
|
|
282
|
+
|
|
283
|
+
const prevScaleRef = useRef( scaleValue );
|
|
284
|
+
const prevFrameSizeRef = useRef( frameSizeValue );
|
|
285
|
+
const prevClientHeightRef = useRef( /* Initialized in the useEffect. */ );
|
|
286
|
+
|
|
255
287
|
const disabledRef = useDisabled( { isDisabled: ! readonly } );
|
|
256
288
|
const bodyRef = useMergeRefs( [
|
|
257
289
|
useBubbleEvents( iframeDocument ),
|
|
@@ -272,6 +304,7 @@ function Iframe( {
|
|
|
272
304
|
<html>
|
|
273
305
|
<head>
|
|
274
306
|
<meta charset="utf-8">
|
|
307
|
+
<base href="${ window.location.origin }">
|
|
275
308
|
<script>window.frameElement._load()</script>
|
|
276
309
|
<style>
|
|
277
310
|
html{
|
|
@@ -303,47 +336,176 @@ function Iframe( {
|
|
|
303
336
|
|
|
304
337
|
useEffect( () => cleanup, [ cleanup ] );
|
|
305
338
|
|
|
306
|
-
const zoomOutAnimationClassnameRef = useRef( null );
|
|
307
|
-
|
|
308
|
-
// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
|
|
309
|
-
// that controls settings the CSS variables, but then we would need to do more work to ensure we're
|
|
310
|
-
// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
|
|
311
|
-
// number of dependencies.
|
|
312
339
|
useEffect( () => {
|
|
313
|
-
if (
|
|
340
|
+
if (
|
|
341
|
+
! iframeDocument ||
|
|
342
|
+
// HACK: Checking if isZoomedOut differs from prevIsZoomedOut here
|
|
343
|
+
// instead of the dependency array to appease the linter.
|
|
344
|
+
( scaleValue === 1 ) === ( prevScaleRef.current === 1 )
|
|
345
|
+
) {
|
|
314
346
|
return;
|
|
315
347
|
}
|
|
316
348
|
|
|
317
|
-
|
|
318
|
-
|
|
349
|
+
// Unscaled height of the current iframe container.
|
|
350
|
+
const clientHeight = iframeDocument.documentElement.clientHeight;
|
|
351
|
+
|
|
352
|
+
// Scaled height of the current iframe content.
|
|
353
|
+
const scrollHeight = iframeDocument.documentElement.scrollHeight;
|
|
354
|
+
|
|
355
|
+
// Previous scale value.
|
|
356
|
+
const prevScale = prevScaleRef.current;
|
|
357
|
+
|
|
358
|
+
// Unscaled size of the previous padding around the iframe content.
|
|
359
|
+
const prevFrameSize = prevFrameSizeRef.current;
|
|
360
|
+
|
|
361
|
+
// Unscaled height of the previous iframe container.
|
|
362
|
+
const prevClientHeight = prevClientHeightRef.current ?? clientHeight;
|
|
363
|
+
|
|
364
|
+
// We can't trust the set value from contentHeight, as it was measured
|
|
365
|
+
// before the zoom out mode was changed. After zoom out mode is changed,
|
|
366
|
+
// appenders may appear or disappear, so we need to get the height from
|
|
367
|
+
// the iframe at this point when we're about to animate the zoom out.
|
|
368
|
+
// The iframe scrollTop, scrollHeight, and clientHeight will all be
|
|
369
|
+
// accurate. The client height also does change when the zoom out mode
|
|
370
|
+
// is toggled, as the bottom bar about selecting the template is
|
|
371
|
+
// added/removed when toggling zoom out mode.
|
|
372
|
+
const scrollTop = iframeDocument.documentElement.scrollTop;
|
|
373
|
+
|
|
374
|
+
// Step 0: Start with the current scrollTop.
|
|
375
|
+
let scrollTopNext = scrollTop;
|
|
376
|
+
|
|
377
|
+
// Step 1: Undo the effects of the previous scale and frame around the
|
|
378
|
+
// midpoint of the visible area.
|
|
379
|
+
scrollTopNext =
|
|
380
|
+
( scrollTopNext + prevClientHeight / 2 - prevFrameSize ) /
|
|
381
|
+
prevScale -
|
|
382
|
+
prevClientHeight / 2;
|
|
383
|
+
|
|
384
|
+
// Step 2: Apply the new scale and frame around the midpoint of the
|
|
385
|
+
// visible area.
|
|
386
|
+
scrollTopNext =
|
|
387
|
+
( scrollTopNext + clientHeight / 2 ) * scaleValue +
|
|
388
|
+
frameSizeValue -
|
|
389
|
+
clientHeight / 2;
|
|
390
|
+
|
|
391
|
+
// Step 3: Handle an edge case so that you scroll to the top of the
|
|
392
|
+
// iframe if the top of the iframe content is visible in the container.
|
|
393
|
+
// The same edge case for the bottom is skipped because changing content
|
|
394
|
+
// makes calculating it impossible.
|
|
395
|
+
scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
|
|
396
|
+
|
|
397
|
+
// This is the scrollTop value if you are scrolled to the bottom of the
|
|
398
|
+
// iframe. We can't just let the browser handle it because we need to
|
|
399
|
+
// animate the scaling.
|
|
400
|
+
const maxScrollTop =
|
|
401
|
+
scrollHeight * ( scaleValue / prevScale ) +
|
|
402
|
+
frameSizeValue * 2 -
|
|
403
|
+
clientHeight;
|
|
404
|
+
|
|
405
|
+
// Step 4: Clamp the scrollTopNext between the minimum and maximum
|
|
406
|
+
// possible scrollTop positions. Round the value to avoid subpixel
|
|
407
|
+
// truncation by the browser which sometimes causes a 1px error.
|
|
408
|
+
scrollTopNext = Math.round(
|
|
409
|
+
Math.min(
|
|
410
|
+
Math.max( 0, scrollTopNext ),
|
|
411
|
+
Math.max( 0, maxScrollTop )
|
|
412
|
+
)
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
iframeDocument.documentElement.style.setProperty(
|
|
416
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top',
|
|
417
|
+
`${ scrollTop }px`
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
iframeDocument.documentElement.style.setProperty(
|
|
421
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top-next',
|
|
422
|
+
`${ scrollTopNext }px`
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
iframeDocument.documentElement.classList.add( 'zoom-out-animation' );
|
|
319
426
|
|
|
320
|
-
|
|
427
|
+
function onZoomOutTransitionEnd() {
|
|
428
|
+
// Remove the position fixed for the animation.
|
|
429
|
+
iframeDocument.documentElement.classList.remove(
|
|
321
430
|
'zoom-out-animation'
|
|
322
431
|
);
|
|
323
432
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
433
|
+
// Update previous values.
|
|
434
|
+
prevClientHeightRef.current = clientHeight;
|
|
435
|
+
prevFrameSizeRef.current = frameSizeValue;
|
|
436
|
+
prevScaleRef.current = scaleValue;
|
|
437
|
+
|
|
438
|
+
// Set the final scroll position that was just animated to.
|
|
439
|
+
// Disable reason: Eslint isn't smart enough to know that this is a
|
|
440
|
+
// DOM element. https://github.com/facebook/react/issues/31483
|
|
441
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
442
|
+
iframeDocument.documentElement.scrollTop = scrollTopNext;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let raf;
|
|
446
|
+
if ( prefersReducedMotion ) {
|
|
447
|
+
// Hack: Wait for the window values to recalculate.
|
|
448
|
+
raf = iframeDocument.defaultView.requestAnimationFrame(
|
|
449
|
+
onZoomOutTransitionEnd
|
|
450
|
+
);
|
|
451
|
+
} else {
|
|
452
|
+
iframeDocument.documentElement.addEventListener(
|
|
453
|
+
'transitionend',
|
|
454
|
+
onZoomOutTransitionEnd,
|
|
455
|
+
{ once: true }
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return () => {
|
|
460
|
+
iframeDocument.documentElement.style.removeProperty(
|
|
461
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top'
|
|
462
|
+
);
|
|
463
|
+
iframeDocument.documentElement.style.removeProperty(
|
|
464
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top-next'
|
|
465
|
+
);
|
|
466
|
+
iframeDocument.documentElement.classList.remove(
|
|
467
|
+
'zoom-out-animation'
|
|
468
|
+
);
|
|
469
|
+
if ( prefersReducedMotion ) {
|
|
470
|
+
iframeDocument.defaultView.cancelAnimationFrame( raf );
|
|
471
|
+
} else {
|
|
472
|
+
iframeDocument.documentElement.removeEventListener(
|
|
473
|
+
'transitionend',
|
|
474
|
+
onZoomOutTransitionEnd
|
|
327
475
|
);
|
|
328
|
-
}
|
|
476
|
+
}
|
|
329
477
|
};
|
|
478
|
+
}, [ iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion ] );
|
|
330
479
|
|
|
331
|
-
|
|
332
|
-
|
|
480
|
+
// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
|
|
481
|
+
// that controls settings the CSS variables, but then we would need to do more work to ensure we're
|
|
482
|
+
// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
|
|
483
|
+
// number of dependencies.
|
|
484
|
+
useEffect( () => {
|
|
485
|
+
if ( ! iframeDocument ) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
333
488
|
|
|
334
|
-
|
|
335
|
-
|
|
489
|
+
if ( isZoomedOut ) {
|
|
490
|
+
iframeDocument.documentElement.classList.add( 'is-zoomed-out' );
|
|
491
|
+
} else {
|
|
492
|
+
// HACK: Since we can't remove this in the cleanup, we need to do it here.
|
|
336
493
|
iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return () => {
|
|
497
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
498
|
+
// animation. More refactoring is needed to fix this properly.
|
|
499
|
+
// iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
|
|
337
500
|
};
|
|
338
501
|
}, [ iframeDocument, isZoomedOut ] );
|
|
339
502
|
|
|
340
503
|
// Calculate the scaling and CSS variables for the zoom out canvas
|
|
341
504
|
useEffect( () => {
|
|
342
|
-
if ( ! iframeDocument
|
|
505
|
+
if ( ! iframeDocument ) {
|
|
343
506
|
return;
|
|
344
507
|
}
|
|
345
508
|
|
|
346
|
-
const maxWidth = 750;
|
|
347
509
|
// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
|
|
348
510
|
// initialContainerWidthRef will be smaller than the full page, and reflow will happen
|
|
349
511
|
// when the canvas area becomes larger due to sidebars closing. This is a known but
|
|
@@ -354,11 +516,7 @@ function Iframe( {
|
|
|
354
516
|
// but calc( 100px / 2px ) is not.
|
|
355
517
|
iframeDocument.documentElement.style.setProperty(
|
|
356
518
|
'--wp-block-editor-iframe-zoom-out-scale',
|
|
357
|
-
|
|
358
|
-
? ( Math.min( containerWidth, maxWidth ) -
|
|
359
|
-
parseInt( frameSize ) * 2 ) /
|
|
360
|
-
scaleContainerWidth
|
|
361
|
-
: scale
|
|
519
|
+
scaleValue
|
|
362
520
|
);
|
|
363
521
|
|
|
364
522
|
// frameSize has to be a px value for the scaling and frame size to be computed correctly.
|
|
@@ -384,27 +542,29 @@ function Iframe( {
|
|
|
384
542
|
);
|
|
385
543
|
|
|
386
544
|
return () => {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
545
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
546
|
+
// animation. More refactoring is needed to fix this properly.
|
|
547
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
548
|
+
// '--wp-block-editor-iframe-zoom-out-scale'
|
|
549
|
+
// );
|
|
550
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
551
|
+
// '--wp-block-editor-iframe-zoom-out-frame-size'
|
|
552
|
+
// );
|
|
553
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
554
|
+
// '--wp-block-editor-iframe-zoom-out-content-height'
|
|
555
|
+
// );
|
|
556
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
557
|
+
// '--wp-block-editor-iframe-zoom-out-inner-height'
|
|
558
|
+
// );
|
|
559
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
560
|
+
// '--wp-block-editor-iframe-zoom-out-container-width'
|
|
561
|
+
// );
|
|
562
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
563
|
+
// '--wp-block-editor-iframe-zoom-out-scale-container-width'
|
|
564
|
+
// );
|
|
405
565
|
};
|
|
406
566
|
}, [
|
|
407
|
-
|
|
567
|
+
scaleValue,
|
|
408
568
|
frameSize,
|
|
409
569
|
iframeDocument,
|
|
410
570
|
iframeWindowInnerHeight,
|
|
@@ -85,10 +85,10 @@ function PatternList( {
|
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
if ( selectedCategory === 'uncategorized' ) {
|
|
88
|
-
const hasKnownCategory =
|
|
89
|
-
( category ) =>
|
|
88
|
+
const hasKnownCategory =
|
|
89
|
+
pattern.categories?.some( ( category ) =>
|
|
90
90
|
registeredPatternCategories.includes( category )
|
|
91
|
-
|
|
91
|
+
) ?? false;
|
|
92
92
|
|
|
93
93
|
return ! pattern.categories?.length || ! hasKnownCategory;
|
|
94
94
|
}
|
|
@@ -151,9 +151,6 @@ function PatternList( {
|
|
|
151
151
|
{ hasItems && (
|
|
152
152
|
<>
|
|
153
153
|
<BlockPatternsList
|
|
154
|
-
shownPatterns={
|
|
155
|
-
pagingProps.categoryPatternsAsyncList
|
|
156
|
-
}
|
|
157
154
|
blockPatterns={ pagingProps.categoryPatterns }
|
|
158
155
|
onClickPattern={ onClickPattern }
|
|
159
156
|
isDraggable={ false }
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
__experimentalText as Text,
|
|
18
18
|
FlexBlock,
|
|
19
19
|
} from '@wordpress/components';
|
|
20
|
-
import { useSelect } from '@wordpress/data';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Internal dependencies
|
|
@@ -31,10 +30,9 @@ import {
|
|
|
31
30
|
isPatternFiltered,
|
|
32
31
|
allPatternsCategory,
|
|
33
32
|
myPatternsCategory,
|
|
33
|
+
starterPatternsCategory,
|
|
34
34
|
INSERTER_PATTERN_TYPES,
|
|
35
35
|
} from './utils';
|
|
36
|
-
import { store as blockEditorStore } from '../../../store';
|
|
37
|
-
import { unlock } from '../../../lock-unlock';
|
|
38
36
|
|
|
39
37
|
const noop = () => {};
|
|
40
38
|
|
|
@@ -45,10 +43,6 @@ export function PatternCategoryPreviews( {
|
|
|
45
43
|
category,
|
|
46
44
|
showTitlesAsTooltip,
|
|
47
45
|
} ) {
|
|
48
|
-
const isZoomOutMode = useSelect(
|
|
49
|
-
( select ) => unlock( select( blockEditorStore ) ).isZoomOut(),
|
|
50
|
-
[]
|
|
51
|
-
);
|
|
52
46
|
const [ allPatterns, , onClickPattern ] = usePatternsState(
|
|
53
47
|
onInsert,
|
|
54
48
|
rootClientId,
|
|
@@ -86,6 +80,13 @@ export function PatternCategoryPreviews( {
|
|
|
86
80
|
return true;
|
|
87
81
|
}
|
|
88
82
|
|
|
83
|
+
if (
|
|
84
|
+
category.name === starterPatternsCategory.name &&
|
|
85
|
+
pattern.blockTypes?.includes( 'core/post-content' )
|
|
86
|
+
) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
|
|
89
90
|
if ( category.name === 'uncategorized' ) {
|
|
90
91
|
// The uncategorized category should show all the patterns without any category...
|
|
91
92
|
if ( ! pattern.categories ) {
|
|
@@ -171,18 +172,15 @@ export function PatternCategoryPreviews( {
|
|
|
171
172
|
</VStack>
|
|
172
173
|
{ currentCategoryPatterns.length > 0 && (
|
|
173
174
|
<>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</Text>
|
|
182
|
-
) }
|
|
175
|
+
<Text
|
|
176
|
+
size="12"
|
|
177
|
+
as="p"
|
|
178
|
+
className="block-editor-inserter__help-text"
|
|
179
|
+
>
|
|
180
|
+
{ __( 'Drag and drop patterns into the canvas.' ) }
|
|
181
|
+
</Text>
|
|
183
182
|
<BlockPatternsList
|
|
184
183
|
ref={ scrollContainerRef }
|
|
185
|
-
shownPatterns={ pagingProps.categoryPatternsAsyncList }
|
|
186
184
|
blockPatterns={ pagingProps.categoryPatterns }
|
|
187
185
|
onClickPattern={ onClickPattern }
|
|
188
186
|
onHover={ onHover }
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isPatternFiltered,
|
|
15
15
|
allPatternsCategory,
|
|
16
16
|
myPatternsCategory,
|
|
17
|
+
starterPatternsCategory,
|
|
17
18
|
INSERTER_PATTERN_TYPES,
|
|
18
19
|
} from './utils';
|
|
19
20
|
|
|
@@ -67,6 +68,13 @@ export function usePatternCategories( rootClientId, sourceFilter = 'all' ) {
|
|
|
67
68
|
label: _x( 'Uncategorized' ),
|
|
68
69
|
} );
|
|
69
70
|
}
|
|
71
|
+
if (
|
|
72
|
+
filteredPatterns.some( ( pattern ) =>
|
|
73
|
+
pattern.blockTypes?.includes( 'core/post-content' )
|
|
74
|
+
)
|
|
75
|
+
) {
|
|
76
|
+
categories.unshift( starterPatternsCategory );
|
|
77
|
+
}
|
|
70
78
|
if (
|
|
71
79
|
filteredPatterns.some(
|
|
72
80
|
( pattern ) => pattern.type === INSERTER_PATTERN_TYPES.user
|
|
@@ -25,6 +25,11 @@ export const myPatternsCategory = {
|
|
|
25
25
|
label: __( 'My patterns' ),
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
export const starterPatternsCategory = {
|
|
29
|
+
name: 'core/starter-content',
|
|
30
|
+
label: __( 'Starter content' ),
|
|
31
|
+
};
|
|
32
|
+
|
|
28
33
|
export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
|
|
29
34
|
const isUserPattern = pattern.name.startsWith( 'core/block' );
|
|
30
35
|
const isDirectoryPattern =
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
privateApis as componentsPrivateApis,
|
|
7
7
|
__unstableMotion as motion,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
|
-
import { useState
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -35,14 +35,13 @@ function CategoryTabs( {
|
|
|
35
35
|
const selectedTabId = selectedCategory ? selectedCategory.name : null;
|
|
36
36
|
const [ activeTabId, setActiveId ] = useState();
|
|
37
37
|
const firstTabId = categories?.[ 0 ]?.name;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}, [ selectedTabId, activeTabId, firstTabId, setActiveId ] );
|
|
38
|
+
|
|
39
|
+
// If there is no active tab, make the first tab the active tab, so that
|
|
40
|
+
// when focus is moved to the tablist, the first tab will be focused
|
|
41
|
+
// despite not being selected
|
|
42
|
+
if ( selectedTabId === null && ! activeTabId && firstTabId ) {
|
|
43
|
+
setActiveId( firstTabId );
|
|
44
|
+
}
|
|
46
45
|
|
|
47
46
|
return (
|
|
48
47
|
<Tabs
|
|
@@ -94,7 +94,12 @@ const useBlockTypesState = ( rootClientId, onInsert, isQuick ) => {
|
|
|
94
94
|
destinationClientId
|
|
95
95
|
);
|
|
96
96
|
},
|
|
97
|
-
[
|
|
97
|
+
[
|
|
98
|
+
getClosestAllowedInsertionPoint,
|
|
99
|
+
rootClientId,
|
|
100
|
+
onInsert,
|
|
101
|
+
createErrorNotice,
|
|
102
|
+
]
|
|
98
103
|
);
|
|
99
104
|
|
|
100
105
|
return [ items, categories, collections, onSelectItem ];
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useMemo, useState, useEffect } from '@wordpress/element';
|
|
5
|
-
import {
|
|
5
|
+
import { usePrevious } from '@wordpress/compose';
|
|
6
6
|
import { getScrollContainer } from '@wordpress/dom';
|
|
7
7
|
|
|
8
8
|
const PAGE_SIZE = 20;
|
|
9
|
-
const INITIAL_INSERTER_RESULTS = 5;
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Supplies values needed to page the patterns list client side.
|
|
@@ -42,9 +41,6 @@ export default function usePatternsPaging(
|
|
|
42
41
|
pageIndex * PAGE_SIZE + PAGE_SIZE
|
|
43
42
|
);
|
|
44
43
|
}, [ pageIndex, currentCategoryPatterns ] );
|
|
45
|
-
const categoryPatternsAsyncList = useAsyncList( categoryPatterns, {
|
|
46
|
-
step: INITIAL_INSERTER_RESULTS,
|
|
47
|
-
} );
|
|
48
44
|
const numPages = Math.ceil( currentCategoryPatterns.length / PAGE_SIZE );
|
|
49
45
|
const changePage = ( page ) => {
|
|
50
46
|
const scrollContainer = getScrollContainer(
|
|
@@ -68,7 +64,6 @@ export default function usePatternsPaging(
|
|
|
68
64
|
return {
|
|
69
65
|
totalItems,
|
|
70
66
|
categoryPatterns,
|
|
71
|
-
categoryPatternsAsyncList,
|
|
72
67
|
numPages,
|
|
73
68
|
changePage,
|
|
74
69
|
currentPage,
|
|
@@ -159,11 +159,6 @@ function InserterSearchResults( {
|
|
|
159
159
|
const currentShownBlockTypes = useAsyncList( filteredBlockTypes, {
|
|
160
160
|
step: INITIAL_INSERTER_RESULTS,
|
|
161
161
|
} );
|
|
162
|
-
const currentShownPatterns = useAsyncList(
|
|
163
|
-
currentShownBlockTypes.length === filteredBlockTypes.length
|
|
164
|
-
? filteredBlockPatterns
|
|
165
|
-
: EMPTY_ARRAY
|
|
166
|
-
);
|
|
167
162
|
|
|
168
163
|
const hasItems =
|
|
169
164
|
filteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0;
|
|
@@ -190,7 +185,6 @@ function InserterSearchResults( {
|
|
|
190
185
|
>
|
|
191
186
|
<div className="block-editor-inserter__quick-inserter-patterns">
|
|
192
187
|
<BlockPatternsList
|
|
193
|
-
shownPatterns={ currentShownPatterns }
|
|
194
188
|
blockPatterns={ filteredBlockPatterns }
|
|
195
189
|
onClickPattern={ onClickPattern }
|
|
196
190
|
onHover={ onHoverPattern }
|
|
@@ -29,6 +29,15 @@ const InserterDraggableBlocks = ( {
|
|
|
29
29
|
blocks,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const blocksContainMedia =
|
|
33
|
+
blocks.filter(
|
|
34
|
+
( block ) =>
|
|
35
|
+
( block.name === 'core/image' ||
|
|
36
|
+
block.name === 'core/audio' ||
|
|
37
|
+
block.name === 'core/video' ) &&
|
|
38
|
+
( block.attributes.url || block.attributes.src )
|
|
39
|
+
).length > 0;
|
|
40
|
+
|
|
32
41
|
const blockTypeIcon = useSelect(
|
|
33
42
|
( select ) => {
|
|
34
43
|
const { getBlockType } = select( blocksStore );
|
|
@@ -63,7 +72,7 @@ const InserterDraggableBlocks = ( {
|
|
|
63
72
|
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
|
|
64
73
|
: blocks;
|
|
65
74
|
event.dataTransfer.setData(
|
|
66
|
-
'text/html',
|
|
75
|
+
blocksContainMedia ? 'default' : 'text/html',
|
|
67
76
|
serialize( parsedBlocks )
|
|
68
77
|
);
|
|
69
78
|
} }
|
|
@@ -116,6 +116,7 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
|
|
|
116
116
|
|
|
117
117
|
<TextControl
|
|
118
118
|
__nextHasNoMarginBottom
|
|
119
|
+
__next40pxDefaultSize
|
|
119
120
|
label="Text Field"
|
|
120
121
|
help="Additional help text"
|
|
121
122
|
value={ textField }
|
|
@@ -208,6 +209,7 @@ function MyBlockEdit( { attributes, setAttributes } ) {
|
|
|
208
209
|
<InspectorAdvancedControls>
|
|
209
210
|
<TextControl
|
|
210
211
|
__nextHasNoMarginBottom
|
|
212
|
+
__next40pxDefaultSize
|
|
211
213
|
label="HTML anchor"
|
|
212
214
|
value={ attributes.anchor }
|
|
213
215
|
onChange={ ( nextValue ) => {
|
|
@@ -34,14 +34,14 @@ export default function InspectorControlsSlot( {
|
|
|
34
34
|
);
|
|
35
35
|
group = __experimentalGroup;
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
const fills = useSlotFills(
|
|
37
|
+
const slotFill = groups[ group ];
|
|
38
|
+
const fills = useSlotFills( slotFill?.name );
|
|
39
39
|
|
|
40
40
|
const motionContextValue = useContext( MotionContext );
|
|
41
41
|
|
|
42
42
|
const computedFillProps = useMemo(
|
|
43
43
|
() => ( {
|
|
44
|
-
...
|
|
44
|
+
...fillProps,
|
|
45
45
|
forwardedContext: [
|
|
46
46
|
...( fillProps?.forwardedContext ?? [] ),
|
|
47
47
|
[ MotionContext.Provider, { value: motionContextValue } ],
|
|
@@ -50,7 +50,7 @@ export default function InspectorControlsSlot( {
|
|
|
50
50
|
[ motionContextValue, fillProps ]
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
if ( !
|
|
53
|
+
if ( ! slotFill ) {
|
|
54
54
|
warning( `Unknown InspectorControls group "${ group }" provided.` );
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
@@ -59,6 +59,8 @@ export default function InspectorControlsSlot( {
|
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const { Slot } = slotFill;
|
|
63
|
+
|
|
62
64
|
if ( label ) {
|
|
63
65
|
return (
|
|
64
66
|
<BlockSupportToolsPanel group={ group } label={ label }>
|
|
@@ -53,9 +53,7 @@ const PositionControlsPanel = () => {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const PositionControls = () => {
|
|
56
|
-
const fills = useSlotFills(
|
|
57
|
-
InspectorControlsGroups.position.Slot.__unstableName
|
|
58
|
-
);
|
|
56
|
+
const fills = useSlotFills( InspectorControlsGroups.position.name );
|
|
59
57
|
const hasFills = Boolean( fills && fills.length );
|
|
60
58
|
|
|
61
59
|
if ( ! hasFills ) {
|