@wordpress/block-editor 14.6.0 → 14.7.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-list/block.js +14 -28
- package/build/components/block-list/block.js.map +1 -1
- 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-toolbar/change-design.js +1 -4
- package/build/components/block-toolbar/change-design.js.map +1 -1
- 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/global-styles/dimensions-panel.js +26 -14
- package/build/components/global-styles/dimensions-panel.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 +16 -0
- 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 +3 -1
- 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/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/media-placeholder/index.js +4 -4
- 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/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/supports.js +6 -6
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +5 -5
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +2 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/private-selectors.js +2 -2
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +9 -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-list/block.js +15 -27
- package/build-module/components/block-list/block.js.map +1 -1
- 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-toolbar/change-design.js +1 -4
- package/build-module/components/block-toolbar/change-design.js.map +1 -1
- 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/global-styles/dimensions-panel.js +26 -14
- package/build-module/components/global-styles/dimensions-panel.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 +16 -0
- 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 +4 -2
- 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/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/media-placeholder/index.js +4 -4
- 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/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/supports.js +6 -6
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +5 -5
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +2 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +9 -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 +7 -6
- package/build-style/content.css +7 -6
- package/build-style/style-rtl.css +14 -3
- package/build-style/style.css +14 -3
- package/build-types/utils/dom.d.ts +7 -9
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/block-canvas/style.scss +1 -1
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-list/block.js +28 -48
- 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-toolbar/change-design.js +1 -7
- 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/default-block-appender/content.scss +13 -19
- package/src/components/global-styles/dimensions-panel.js +22 -16
- package/src/components/iframe/get-compatibility-styles.js +4 -9
- package/src/components/iframe/index.js +17 -0
- 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 +8 -1
- 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/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/media-placeholder/index.js +4 -4
- 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/font-family.js +1 -1
- package/src/hooks/supports.js +6 -6
- package/src/hooks/typography.js +5 -5
- package/src/hooks/utils.js +7 -2
- package/src/store/private-selectors.js +5 -6
- package/src/store/selectors.js +57 -45
- package/src/store/test/private-selectors.js +5 -0
- package/src/store/utils.js +12 -11
- 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/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Async = Async;
|
|
7
|
+
var _element = require("@wordpress/element");
|
|
8
|
+
var _priorityQueue = require("@wordpress/priority-queue");
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const blockPreviewQueue = (0, _priorityQueue.createQueue)();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Renders a component at the next idle time.
|
|
17
|
+
* @param {*} props
|
|
18
|
+
*/
|
|
19
|
+
function Async({
|
|
20
|
+
children,
|
|
21
|
+
placeholder
|
|
22
|
+
}) {
|
|
23
|
+
const [shouldRender, setShouldRender] = (0, _element.useState)(false);
|
|
24
|
+
|
|
25
|
+
// In the future, we could try to use startTransition here, but currently
|
|
26
|
+
// react will batch all transitions, which means all previews will be
|
|
27
|
+
// rendered at the same time.
|
|
28
|
+
// https://react.dev/reference/react/startTransition#caveats
|
|
29
|
+
// > If there are multiple ongoing Transitions, React currently batches them
|
|
30
|
+
// > together. This is a limitation that will likely be removed in a future
|
|
31
|
+
// > release.
|
|
32
|
+
|
|
33
|
+
(0, _element.useEffect)(() => {
|
|
34
|
+
const context = {};
|
|
35
|
+
blockPreviewQueue.add(context, () => {
|
|
36
|
+
// Synchronously run all renders so it consumes timeRemaining.
|
|
37
|
+
// See https://github.com/WordPress/gutenberg/pull/48238
|
|
38
|
+
(0, _element.flushSync)(() => {
|
|
39
|
+
setShouldRender(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
blockPreviewQueue.cancel(context);
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
if (!shouldRender) {
|
|
47
|
+
return placeholder;
|
|
48
|
+
}
|
|
49
|
+
return children;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_element","require","_priorityQueue","blockPreviewQueue","createQueue","Async","children","placeholder","shouldRender","setShouldRender","useState","useEffect","context","add","flushSync","cancel"],"sources":["@wordpress/block-editor/src/components/block-preview/async.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, flushSync } from '@wordpress/element';\nimport { createQueue } from '@wordpress/priority-queue';\n\nconst blockPreviewQueue = createQueue();\n\n/**\n * Renders a component at the next idle time.\n * @param {*} props\n */\nexport function Async( { children, placeholder } ) {\n\tconst [ shouldRender, setShouldRender ] = useState( false );\n\n\t// In the future, we could try to use startTransition here, but currently\n\t// react will batch all transitions, which means all previews will be\n\t// rendered at the same time.\n\t// https://react.dev/reference/react/startTransition#caveats\n\t// > If there are multiple ongoing Transitions, React currently batches them\n\t// > together. This is a limitation that will likely be removed in a future\n\t// > release.\n\n\tuseEffect( () => {\n\t\tconst context = {};\n\t\tblockPreviewQueue.add( context, () => {\n\t\t\t// Synchronously run all renders so it consumes timeRemaining.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/48238\n\t\t\tflushSync( () => {\n\t\t\t\tsetShouldRender( true );\n\t\t\t} );\n\t\t} );\n\t\treturn () => {\n\t\t\tblockPreviewQueue.cancel( context );\n\t\t};\n\t}, [] );\n\n\tif ( ! shouldRender ) {\n\t\treturn placeholder;\n\t}\n\n\treturn children;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,MAAME,iBAAiB,GAAG,IAAAC,0BAAW,EAAC,CAAC;;AAEvC;AACA;AACA;AACA;AACO,SAASC,KAAKA,CAAE;EAAEC,QAAQ;EAAEC;AAAY,CAAC,EAAG;EAClD,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;;EAE3D;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,IAAAC,kBAAS,EAAE,MAAM;IAChB,MAAMC,OAAO,GAAG,CAAC,CAAC;IAClBT,iBAAiB,CAACU,GAAG,CAAED,OAAO,EAAE,MAAM;MACrC;MACA;MACA,IAAAE,kBAAS,EAAE,MAAM;QAChBL,eAAe,CAAE,IAAK,CAAC;MACxB,CAAE,CAAC;IACJ,CAAE,CAAC;IACH,OAAO,MAAM;MACZN,iBAAiB,CAACY,MAAM,CAAEH,OAAQ,CAAC;IACpC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEJ,YAAY,EAAG;IACrB,OAAOD,WAAW;EACnB;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
|
|
@@ -17,6 +17,7 @@ var _auto = _interopRequireDefault(require("./auto"));
|
|
|
17
17
|
var _editorStyles = _interopRequireDefault(require("../editor-styles"));
|
|
18
18
|
var _store = require("../../store");
|
|
19
19
|
var _blockList = require("../block-list");
|
|
20
|
+
var _async = require("./async");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
22
|
/**
|
|
22
23
|
* External dependencies
|
|
@@ -79,6 +80,8 @@ function BlockPreview({
|
|
|
79
80
|
})
|
|
80
81
|
});
|
|
81
82
|
}
|
|
83
|
+
const MemoizedBlockPreview = (0, _element.memo)(BlockPreview);
|
|
84
|
+
MemoizedBlockPreview.Async = _async.Async;
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
87
|
* BlockPreview renders a preview of a block or array of blocks.
|
|
@@ -91,7 +94,7 @@ function BlockPreview({
|
|
|
91
94
|
*
|
|
92
95
|
* @return {Component} The component to be rendered.
|
|
93
96
|
*/
|
|
94
|
-
var _default = exports.default =
|
|
97
|
+
var _default = exports.default = MemoizedBlockPreview;
|
|
95
98
|
/**
|
|
96
99
|
* This hook is used to lightly mark an element as a block preview wrapper
|
|
97
100
|
* element. Call this hook and pass the returned props to the element to mark as
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_data","_element","_deprecated","_provider","_auto","_editorStyles","_store","_blockList","_jsxRuntime","EMPTY_ADDITIONAL_STYLES","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","deprecated","since","version","alternative","css","originalSettings","useSelect","select","blockEditorStore","getSettings","settings","useMemo","focusMode","isPreviewMode","renderedBlocks","Array","isArray","length","jsx","ExperimentalBlockEditorProvider","value","children","default","
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_data","_element","_deprecated","_provider","_auto","_editorStyles","_store","_blockList","_async","_jsxRuntime","EMPTY_ADDITIONAL_STYLES","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","deprecated","since","version","alternative","css","originalSettings","useSelect","select","blockEditorStore","getSettings","settings","useMemo","focusMode","isPreviewMode","renderedBlocks","Array","isArray","length","jsx","ExperimentalBlockEditorProvider","value","children","default","MemoizedBlockPreview","memo","Async","_default","exports","useBlockPreview","props","layout","styles","undefined","disabledRef","useDisabled","ref","useMergeRefs","jsxs","BlockListItems","renderAppender","className","clsx"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\nimport { Async } from './async';\n\nconst EMPTY_ADDITIONAL_STYLES = [];\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = EMPTY_ADDITIONAL_STYLES,\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nconst MemoizedBlockPreview = memo( BlockPreview );\n\nMemoizedBlockPreview.Async = Async;\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {Component} The component to be rendered.\n */\nexport default MemoizedBlockPreview;\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AAKA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GA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C,CAAE,EACH,CAAER,gBAAgB,CACnB,CAAC;EACD,MAAM4B,WAAW,GAAG,IAAAC,oBAAW,EAAC,CAAC;EACjC,MAAMC,GAAG,GAAG,IAAAC,qBAAY,EAAE,CAAEP,KAAK,CAACM,GAAG,EAAEF,WAAW,CAAG,CAAC;EACtD,MAAMnB,cAAc,GAAG,IAAAH,gBAAO,EAC7B,MAAQI,KAAK,CAACC,OAAO,CAAEtB,MAAO,CAAC,GAAGA,MAAM,GAAG,CAAEA,MAAM,CAAI,EACvD,CAAEA,MAAM,CACT,CAAC;EAED,MAAM2B,QAAQ,gBACb,IAAA9B,WAAA,CAAA8C,IAAA,EAACpD,SAAA,CAAAkC,+BAA+B;IAC/BC,KAAK,EAAGN,cAAgB;IACxBJ,QAAQ,EAAGA,QAAU;IAAAW,QAAA,gBAErB,IAAA9B,WAAA,CAAA2B,GAAA,EAAC/B,aAAA,CAAAmC,OAAY,IAAE,CAAC,eAChB,IAAA/B,WAAA,CAAA2B,GAAA,EAAC7B,UAAA,CAAAiD,cAAc;MAACC,cAAc,EAAG,KAAO;MAACT,MAAM,EAAGA;IAAQ,CAAE,CAAC;EAAA,CAC7B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRM,GAAG;IACHK,SAAS,EAAE,IAAAC,aAAI,EACdZ,KAAK,CAACW,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDnB,QAAQ,EAAE3B,MAAM,EAAEuB,MAAM,GAAGI,QAAQ,GAAG;EACvC,CAAC;AACF","ignoreList":[]}
|
|
@@ -9,7 +9,6 @@ var _components = require("@wordpress/components");
|
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
10
|
var _blocks = require("@wordpress/blocks");
|
|
11
11
|
var _element = require("@wordpress/element");
|
|
12
|
-
var _compose = require("@wordpress/compose");
|
|
13
12
|
var _data = require("@wordpress/data");
|
|
14
13
|
var _store = require("../../store");
|
|
15
14
|
var _blockPatternsList = _interopRequireDefault(require("../block-patterns-list"));
|
|
@@ -78,7 +77,6 @@ function ChangeDesign({
|
|
|
78
77
|
);
|
|
79
78
|
}).slice(0, MAX_PATTERNS_TO_SHOW);
|
|
80
79
|
}, [categories, currentPatternName, patterns]);
|
|
81
|
-
const currentShownPatterns = (0, _compose.useAsyncList)(sameCategoryPatternsWithSingleWrapper);
|
|
82
80
|
if (sameCategoryPatternsWithSingleWrapper.length < 2) {
|
|
83
81
|
return null;
|
|
84
82
|
}
|
|
@@ -111,10 +109,9 @@ function ChangeDesign({
|
|
|
111
109
|
className: "block-editor-block-toolbar-change-design-content-wrapper",
|
|
112
110
|
paddingSize: "none",
|
|
113
111
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockPatternsList.default, {
|
|
114
|
-
shownPatterns: currentShownPatterns,
|
|
115
112
|
blockPatterns: sameCategoryPatternsWithSingleWrapper,
|
|
116
113
|
onClickPattern: onClickPattern,
|
|
117
|
-
|
|
114
|
+
showTitlesAsTooltip: true
|
|
118
115
|
})
|
|
119
116
|
})
|
|
120
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_blocks","_element","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_blocks","_element","_data","_store","_blockPatternsList","_interopRequireDefault","_jsxRuntime","EMPTY_ARRAY","MAX_PATTERNS_TO_SHOW","POPOVER_PROPS","placement","ChangeDesign","clientId","categories","currentPatternName","patterns","useSelect","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","blockEditorStore","attributes","_categories","metadata","rootBlock","_patterns","length","patternName","replaceBlocks","useDispatch","sameCategoryPatternsWithSingleWrapper","useMemo","filter","pattern","isCorePattern","source","startsWith","blocks","name","some","category","includes","syncStatus","id","slice","onClickPattern","_pattern$blocks","newBlocks","map","block","cloneBlock","jsx","Dropdown","popoverProps","renderToggle","onToggle","isOpen","ToolbarGroup","children","ToolbarButton","onClick","__","renderContent","__experimentalDropdownContentWrapper","className","paddingSize","default","blockPatterns","showTitlesAsTooltip"],"sources":["@wordpress/block-editor/src/components/block-toolbar/change-design.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\tToolbarGroup,\n\tDropdown,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockPatternsList from '../block-patterns-list';\n\nconst EMPTY_ARRAY = [];\nconst MAX_PATTERNS_TO_SHOW = 6;\nconst POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\nexport default function ChangeDesign( { clientId } ) {\n\tconst { categories, currentPatternName, patterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\n\t\t\t// Calling `__experimentalGetAllowedPatterns` is expensive.\n\t\t\t// Checking if the block can be changed prevents unnecessary selector calls.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/64736.\n\t\t\tconst _patterns =\n\t\t\t\t_categories.length > 0\n\t\t\t\t\t? __experimentalGetAllowedPatterns( rootBlock )\n\t\t\t\t\t: EMPTY_ARRAY;\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tcurrentPatternName: attributes?.metadata?.patternName,\n\t\t\t\tpatterns: _patterns,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif ( categories.length === 0 || ! patterns || patterns.length === 0 ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns\n\t\t\t.filter( ( pattern ) => {\n\t\t\t\tconst isCorePattern =\n\t\t\t\t\tpattern.source === 'core' ||\n\t\t\t\t\t( pattern.source?.startsWith( 'pattern-directory' ) &&\n\t\t\t\t\t\tpattern.source !== 'pattern-directory/theme' );\n\t\t\t\treturn (\n\t\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t\t// otherwise we may switch to a pattern that doesn't have replacement suggestions.\n\t\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\t\t// We exclude the core patterns and pattern directory patterns that are not theme patterns.\n\t\t\t\t\t! isCorePattern &&\n\t\t\t\t\t// Exclude current pattern.\n\t\t\t\t\tcurrentPatternName !== pattern.name &&\n\t\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t\t} ) &&\n\t\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.slice( 0, MAX_PATTERNS_TO_SHOW );\n\t}, [ categories, currentPatternName, patterns ] );\n\n\tif ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {\n\t\treturn null;\n\t}\n\n\tconst onClickPattern = ( pattern ) => {\n\t\tconst newBlocks = ( pattern.blocks ?? [] ).map( ( block ) => {\n\t\t\treturn cloneBlock( block );\n\t\t} );\n\t\tnewBlocks[ 0 ].attributes.metadata = {\n\t\t\t...newBlocks[ 0 ].attributes.metadata,\n\t\t\tcategories,\n\t\t};\n\t\treplaceBlocks( clientId, newBlocks );\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\trenderToggle={ ( { onToggle, isOpen } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () => onToggle( ! isOpen ) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Change design' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper\n\t\t\t\t\tclassName=\"block-editor-block-toolbar-change-design-content-wrapper\"\n\t\t\t\t\tpaddingSize=\"none\"\n\t\t\t\t>\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tblockPatterns={ sameCategoryPatternsWithSingleWrapper }\n\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAuD,IAAAQ,WAAA,GAAAR,OAAA;AAlBvD;AACA;AACA;;AAYA;AACA;AACA;;AAIA,MAAMS,WAAW,GAAG,EAAE;AACtB,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,aAAa,GAAG;EACrBC,SAAS,EAAE;AACZ,CAAC;AAEc,SAASC,YAAYA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACpD,MAAM;IAAEC,UAAU;IAAEC,kBAAkB;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EAC3DC,MAAM,IAAM;IACb,MAAM;MACLC,kBAAkB;MAClBC,oBAAoB;MACpBC;IACD,CAAC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T;MAAC,CACH,CAAC;IAEjB,CAAG;IACHC,aAAa,EAAGA,CAAA,kBACf,IAAAzD,WAAA,CAAA8C,GAAA,EAACvD,WAAA,CAAAmE,oCAAsB;MACtBC,SAAS,EAAC,0DAA0D;MACpEC,WAAW,EAAC,MAAM;MAAAP,QAAA,eAElB,IAAArD,WAAA,CAAA8C,GAAA,EAAChD,kBAAA,CAAA+D,OAAiB;QACjBC,aAAa,EAAGrC,qCAAuC;QACvDe,cAAc,EAAGA,cAAgB;QACjCuB,mBAAmB;MAAA,CACnB;IAAC,CACqB;EACtB,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -101,19 +101,22 @@ function BlockTools({
|
|
|
101
101
|
if (event.defaultPrevented) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
if (isMatch('core/block-editor/move-up', event)) {
|
|
104
|
+
if (isMatch('core/block-editor/move-up', event) || isMatch('core/block-editor/move-down', event)) {
|
|
105
105
|
const clientIds = getSelectedBlockClientIds();
|
|
106
106
|
if (clientIds.length) {
|
|
107
107
|
event.preventDefault();
|
|
108
108
|
const rootClientId = getBlockRootClientId(clientIds[0]);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
109
|
+
const direction = isMatch('core/block-editor/move-up', event) ? 'up' : 'down';
|
|
110
|
+
if (direction === 'up') {
|
|
111
|
+
moveBlocksUp(clientIds, rootClientId);
|
|
112
|
+
} else {
|
|
113
|
+
moveBlocksDown(clientIds, rootClientId);
|
|
114
|
+
}
|
|
115
|
+
const blockLength = Array.isArray(clientIds) ? clientIds.length : 1;
|
|
116
|
+
const message = (0, _i18n.sprintf)(
|
|
117
|
+
// translators: %d: the name of the block that has been moved
|
|
118
|
+
(0, _i18n._n)('%d block moved.', '%d blocks moved.', clientIds.length), blockLength);
|
|
119
|
+
(0, _a11y.speak)(message);
|
|
117
120
|
}
|
|
118
121
|
} else if (isMatch('core/block-editor/duplicate', event)) {
|
|
119
122
|
const clientIds = getSelectedBlockClientIds();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_dom","_components","_keyboardShortcuts","_element","_blocks","_a11y","_i18n","_emptyBlockInserter","_interopRequireDefault","_insertionPoint","_interopRequireWildcard","_blockToolbarPopover","_store","_usePopoverScroll","_zoomOutModeInserters","_useShowBlockTools","_lockUnlock","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","selector","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getSettings","isTyping","isDragging","isZoomOut","unlock","blockEditorStore","clientId","hasFixedToolbar","isZoomOutMode","BlockTools","children","__unstableContentRef","props","useSelect","isMatch","useShortcutEventMatch","getBlocksByClientId","getSelectedBlockClientIds","getBlockRootClientId","isGroupable","getGroupingBlockName","blocksStore","showEmptyBlockSideInserter","showBlockToolbarPopover","useShowBlockTools","duplicateBlocks","removeBlocks","replaceBlocks","insertAfterBlock","insertBeforeBlock","selectBlock","moveBlocksUp","moveBlocksDown","expandBlock","useDispatch","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","closest","isTextField","contentWindow","document","activeElement","blocks","groupingBlockName","newBlocks","switchToBlockType","speak","__","blockToolbarRef","usePopoverScroll","blockToolbarAfterRef","jsx","jsxs","InsertionPointOpenRef","Provider","value","useRef","Popover","Slot","name","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport { switchToBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAKA,IAAAQ,mBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,eAAA,GAAAC,uBAAA,CAAAX,OAAA;AAIA,IAAAY,oBAAA,GAAAH,sBAAA,CAAAT,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,iBAAA,GAAAL,sBAAA,CAAAT,OAAA;AACA,IAAAe,qBAAA,GAAAN,sBAAA,CAAAT,OAAA;AACA,IAAAgB,kBAAA,GAAAhB,OAAA;AACA,IAAAiB,WAAA,GAAAjB,OAAA;AAA2C,IAAAkB,WAAA,GAAAlB,OAAA;AAAA,SAAAmB,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,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IAAAhC,WAAA,CAAAkF,GAAA,EAAClG,WAAA,CAAAwG,OAAO,CAACC,IAAI;UACZC,IAAI,EAAC,eAAe;UACpBC,GAAG,EAAGZ;QAAiB,CACvB,CACD,EACC5C,QAAQ,eAEV,IAAAnC,WAAA,CAAAkF,GAAA,EAAClG,WAAA,CAAAwG,OAAO,CAACC,IAAI;UACZC,IAAI,EAAC,8BAA8B;UACnCC,GAAG,EAAGV;QAAsB,CAC5B,CAAC,EACAhD,aAAa,IAAI,CAAEN,UAAU,iBAC9B,IAAA3B,WAAA,CAAAkF,GAAA,EAACrF,qBAAA,CAAAU,OAAoB;UACpB6B,oBAAoB,EAAGA;QAAsB,CAC7C,CACD;MAAA,CAC8B;IAAC,CAC7B;EAAC;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_dom","_components","_keyboardShortcuts","_element","_blocks","_a11y","_i18n","_emptyBlockInserter","_interopRequireDefault","_insertionPoint","_interopRequireWildcard","_blockToolbarPopover","_store","_usePopoverScroll","_zoomOutModeInserters","_useShowBlockTools","_lockUnlock","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","selector","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getSettings","isTyping","isDragging","isZoomOut","unlock","blockEditorStore","clientId","hasFixedToolbar","isZoomOutMode","BlockTools","children","__unstableContentRef","props","useSelect","isMatch","useShortcutEventMatch","getBlocksByClientId","getSelectedBlockClientIds","getBlockRootClientId","isGroupable","getGroupingBlockName","blocksStore","showEmptyBlockSideInserter","showBlockToolbarPopover","useShowBlockTools","duplicateBlocks","removeBlocks","replaceBlocks","insertAfterBlock","insertBeforeBlock","selectBlock","moveBlocksUp","moveBlocksDown","expandBlock","useDispatch","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","direction","blockLength","Array","isArray","message","sprintf","_n","speak","target","closest","isTextField","contentWindow","document","activeElement","blocks","groupingBlockName","newBlocks","switchToBlockType","__","blockToolbarRef","usePopoverScroll","blockToolbarAfterRef","jsx","jsxs","InsertionPointOpenRef","Provider","value","useRef","Popover","Slot","name","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport { switchToBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,O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,CAAC,EACAvD,aAAa,IAAI,CAAEN,UAAU,iBAC9B,IAAA3B,WAAA,CAAAyF,GAAA,EAAC5F,qBAAA,CAAAU,OAAoB;UACpB6B,oBAAoB,EAAGA;QAAsB,CAC7C,CACD;MAAA,CAC8B;IAAC,CAC7B;EAAC;AAER","ignoreList":[]}
|
|
@@ -62,7 +62,7 @@ function getProps(contentElement, selectedBlockElement, scrollContainer, toolbar
|
|
|
62
62
|
|
|
63
63
|
// Get how far the content area has been scrolled.
|
|
64
64
|
const scrollTop = scrollContainer?.scrollTop || 0;
|
|
65
|
-
const blockRect = (0, _dom2.
|
|
65
|
+
const blockRect = (0, _dom2.getElementBounds)(selectedBlockElement);
|
|
66
66
|
const contentRect = contentElement.getBoundingClientRect();
|
|
67
67
|
|
|
68
68
|
// Get the vertical position of top of the visible content area.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_data","_dom","_element","_store","_useBlockRefs","_position","_dom2","COMMON_PROPS","placement","DEFAULT_PROPS","flip","shift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","scrollContainer","toolbarHeight","isSticky","scrollTop","blockRect","getVisibleElementBounds","contentRect","getBoundingClientRect","topOfContentElementInViewport","top","viewportHeight","ownerDocument","documentElement","clientHeight","restrictedTopArea","hasSpaceForToolbarAbove","isBlockTallerThanViewport","height","useBlockToolbarPopoverProps","clientId","useBlockElement","setToolbarHeight","useState","blockIndex","useSelect","select","getBlockIndex","getBlockAttributes","blockEditorStore","hasStickyOrFixedPositionValue","useMemo","getScrollContainer","props","setProps","popoverRef","useRefEffect","popoverNode","offsetHeight","updateProps","useCallback","useLayoutEffect","contentView","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { getScrollContainer } from '@wordpress/dom';\nimport {\n\tuseCallback,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { hasStickyOrFixedPositionValue } from '../../hooks/position';\nimport { getVisibleElementBounds } from '../../utils/dom';\n\nconst COMMON_PROPS = {\n\tplacement: 'top-start',\n};\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: false,\n\tshift: true,\n};\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled, which positions the toolbar below\n// the block. This only happens if the block is smaller than the viewport, as\n// otherwise the toolbar will be off-screen.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: true,\n\tshift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {Element} scrollContainer The scrollable container for the contentElement.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n * @param {boolean} isSticky Whether or not the selected block is sticky or fixed.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps(\n\tcontentElement,\n\tselectedBlockElement,\n\tscrollContainer,\n\ttoolbarHeight,\n\tisSticky\n) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\t// Get how far the content area has been scrolled.\n\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\n\tconst blockRect = getVisibleElementBounds( selectedBlockElement );\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\t// Get the vertical position of top of the visible content area.\n\tconst topOfContentElementInViewport = scrollTop + contentRect.top;\n\n\t// The document element's clientHeight represents the viewport height.\n\tconst viewportHeight =\n\t\tcontentElement.ownerDocument.documentElement.clientHeight;\n\n\t// The restricted height area is calculated as the sum of the\n\t// vertical position of the visible content area, plus the height\n\t// of the block toolbar.\n\tconst restrictedTopArea = topOfContentElementInViewport + toolbarHeight;\n\tconst hasSpaceForToolbarAbove = blockRect.top > restrictedTopArea;\n\n\tconst isBlockTallerThanViewport =\n\t\tblockRect.height > viewportHeight - toolbarHeight;\n\n\t// Sticky blocks are treated as if they will never have enough space for the toolbar above.\n\tif (\n\t\t! isSticky &&\n\t\t( hasSpaceForToolbarAbove || isBlockTallerThanViewport )\n\t) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst { blockIndex, isSticky } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockIndex, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\tisSticky: hasStickyOrFixedPositionValue(\n\t\t\t\t\tgetBlockAttributes( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst scrollContainer = useMemo( () => {\n\t\tif ( ! contentElement ) {\n\t\t\treturn;\n\t\t}\n\t\treturn getScrollContainer( contentElement );\n\t}, [ contentElement ] );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps(\n\t\t\tcontentElement,\n\t\t\tselectedBlockElement,\n\t\t\tscrollContainer,\n\t\t\ttoolbarHeight,\n\t\t\tisSticky\n\t\t)\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps(\n\t\t\t\t\tcontentElement,\n\t\t\t\t\tselectedBlockElement,\n\t\t\t\t\tscrollContainer,\n\t\t\t\t\ttoolbarHeight,\n\t\t\t\t\tisSticky\n\t\t\t\t)\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, scrollContainer, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,G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_element","_store","_useBlockRefs","_position","_dom2","COMMON_PROPS","placement","DEFAULT_PROPS","flip","shift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","scrollContainer","toolbarHeight","isSticky","scrollTop","blockRect","getElementBounds","contentRect","getBoundingClientRect","topOfContentElementInViewport","top","viewportHeight","ownerDocument","documentElement","clientHeight","restrictedTopArea","hasSpaceForToolbarAbove","isBlockTallerThanViewport","height","useBlockToolbarPopoverProps","clientId","useBlockElement","setToolbarHeight","useState","blockIndex","useSelect","select","getBlockIndex","getBlockAttributes","blockEditorStore","hasStickyOrFixedPositionValue","useMemo","getScrollContainer","props","setProps","popoverRef","useRefEffect","popoverNode","offsetHeight","updateProps","useCallback","useLayoutEffect","contentView","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { getScrollContainer } from '@wordpress/dom';\nimport {\n\tuseCallback,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { hasStickyOrFixedPositionValue } from '../../hooks/position';\nimport { getElementBounds } from '../../utils/dom';\n\nconst COMMON_PROPS = {\n\tplacement: 'top-start',\n};\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: false,\n\tshift: true,\n};\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled, which positions the toolbar below\n// the block. This only happens if the block is smaller than the viewport, as\n// otherwise the toolbar will be off-screen.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: true,\n\tshift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {Element} scrollContainer The scrollable container for the contentElement.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n * @param {boolean} isSticky Whether or not the selected block is sticky or fixed.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps(\n\tcontentElement,\n\tselectedBlockElement,\n\tscrollContainer,\n\ttoolbarHeight,\n\tisSticky\n) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\t// Get how far the content area has been scrolled.\n\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\n\tconst blockRect = getElementBounds( selectedBlockElement );\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\t// Get the vertical position of top of the visible content area.\n\tconst topOfContentElementInViewport = scrollTop + contentRect.top;\n\n\t// The document element's clientHeight represents the viewport height.\n\tconst viewportHeight =\n\t\tcontentElement.ownerDocument.documentElement.clientHeight;\n\n\t// The restricted height area is calculated as the sum of the\n\t// vertical position of the visible content area, plus the height\n\t// of the block toolbar.\n\tconst restrictedTopArea = topOfContentElementInViewport + toolbarHeight;\n\tconst hasSpaceForToolbarAbove = blockRect.top > restrictedTopArea;\n\n\tconst isBlockTallerThanViewport =\n\t\tblockRect.height > viewportHeight - toolbarHeight;\n\n\t// Sticky blocks are treated as if they will never have enough space for the toolbar above.\n\tif (\n\t\t! isSticky &&\n\t\t( hasSpaceForToolbarAbove || isBlockTallerThanViewport )\n\t) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst { blockIndex, isSticky } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockIndex, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\tisSticky: hasStickyOrFixedPositionValue(\n\t\t\t\t\tgetBlockAttributes( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst scrollContainer = useMemo( () => {\n\t\tif ( ! contentElement ) {\n\t\t\treturn;\n\t\t}\n\t\treturn getScrollContainer( contentElement );\n\t}, [ contentElement ] );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps(\n\t\t\tcontentElement,\n\t\t\tselectedBlockElement,\n\t\t\tscrollContainer,\n\t\t\ttoolbarHeight,\n\t\t\tisSticky\n\t\t)\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps(\n\t\t\t\t\tcontentElement,\n\t\t\t\t\tselectedBlockElement,\n\t\t\t\t\tscrollContainer,\n\t\t\t\t\ttoolbarHeight,\n\t\t\t\t\tisSticky\n\t\t\t\t)\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, scrollContainer, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAUA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAnBA;AACA;AACA;;AAWA;AACA;AACA;;AAMA,MAAMQ,YAAY,GAAG;EACpBC,SAAS,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACA,MAAMC,aAAa,GAAG;EACrB,GAAGF,YAAY;EACfG,IAAI,EAAE,KAAK;EACXC,KAAK,EAAE;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,GAAG;EAC/B,GAAGL,YAAY;EACfG,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;A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E,eAAe,GAAI,QAAQ,EAAEL,WAAY,CAAC;;IAEvD;IACA,IAAIM,cAAc;IAClB,MAAMC,SAAS,GAAG9C,oBAAoB,EAAEY,aAAa,EAAE+B,WAAW;IAClE,IAAKG,SAAS,CAACC,cAAc,EAAG;MAC/BF,cAAc,GAAG,IAAIC,SAAS,CAACC,cAAc,CAAER,WAAY,CAAC;MAC5DM,cAAc,CAACG,OAAO,CAAEhD,oBAAqB,CAAC;IAC/C;IAEA,OAAO,MAAM;MACZ0C,WAAW,EAAEO,kBAAkB,GAAI,QAAQ,EAAEV,WAAY,CAAC;MAE1D,IAAKM,cAAc,EAAG;QACrBA,cAAc,CAACK,UAAU,CAAC,CAAC;MAC5B;IACD,CAAC;EACF,CAAC,EAAE,CAAEX,WAAW,EAAExC,cAAc,EAAEC,oBAAoB,CAAG,CAAC;EAE1D,OAAO;IACN,GAAGiC,KAAK;IACRkB,GAAG,EAAEhB;EACN,CAAC;AACF","ignoreList":[]}
|
|
@@ -37,7 +37,10 @@ function useShowBlockTools() {
|
|
|
37
37
|
const editorMode = __unstableGetEditorMode();
|
|
38
38
|
const hasSelectedBlock = !!clientId && !!block;
|
|
39
39
|
const isEmptyDefaultBlock = hasSelectedBlock && (0, _blocks.isUnmodifiedDefaultBlock)(block) && getBlockMode(clientId) !== 'html';
|
|
40
|
-
const _showEmptyBlockSideInserter = clientId && !isTyping() &&
|
|
40
|
+
const _showEmptyBlockSideInserter = clientId && !isTyping() &&
|
|
41
|
+
// Hide the block inserter on the navigation mode.
|
|
42
|
+
// See https://github.com/WordPress/gutenberg/pull/66636#discussion_r1824728483.
|
|
43
|
+
editorMode !== 'navigation' && isEmptyDefaultBlock;
|
|
41
44
|
const _showBlockToolbarPopover = !getSettings().hasFixedToolbar && !_showEmptyBlockSideInserter && hasSelectedBlock && !isEmptyDefaultBlock;
|
|
42
45
|
return {
|
|
43
46
|
showEmptyBlockSideInserter: _showEmptyBlockSideInserter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blocks","_store","_lockUnlock","useShowBlockTools","useSelect","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlock","getBlockMode","getSettings","__unstableGetEditorMode","isTyping","unlock","blockEditorStore","clientId","block","editorMode","hasSelectedBlock","isEmptyDefaultBlock","isUnmodifiedDefaultBlock","_showEmptyBlockSideInserter","_showBlockToolbarPopover","hasFixedToolbar","showEmptyBlockSideInserter","showBlockToolbarPopover"],"sources":["@wordpress/block-editor/src/components/block-tools/use-show-block-tools.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Source of truth for which block tools are showing in the block editor.\n *\n * @return {Object} Object of which block tools will be shown.\n */\nexport function useShowBlockTools() {\n\treturn useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetFirstMultiSelectedBlockClientId,\n\t\t\tgetBlock,\n\t\t\tgetBlockMode,\n\t\t\tgetSettings,\n\t\t\t__unstableGetEditorMode,\n\t\t\tisTyping,\n\t\t} = unlock( select( blockEditorStore ) );\n\n\t\tconst clientId =\n\t\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\t\tconst block = getBlock( clientId );\n\t\tconst editorMode = __unstableGetEditorMode();\n\t\tconst hasSelectedBlock = !! clientId && !! block;\n\t\tconst isEmptyDefaultBlock =\n\t\t\thasSelectedBlock &&\n\t\t\tisUnmodifiedDefaultBlock( block ) &&\n\t\t\tgetBlockMode( clientId ) !== 'html';\n\t\tconst _showEmptyBlockSideInserter =\n\t\t\tclientId &&\n\t\t\t! isTyping() &&\n\t\t\teditorMode
|
|
1
|
+
{"version":3,"names":["_data","require","_blocks","_store","_lockUnlock","useShowBlockTools","useSelect","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlock","getBlockMode","getSettings","__unstableGetEditorMode","isTyping","unlock","blockEditorStore","clientId","block","editorMode","hasSelectedBlock","isEmptyDefaultBlock","isUnmodifiedDefaultBlock","_showEmptyBlockSideInserter","_showBlockToolbarPopover","hasFixedToolbar","showEmptyBlockSideInserter","showBlockToolbarPopover"],"sources":["@wordpress/block-editor/src/components/block-tools/use-show-block-tools.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Source of truth for which block tools are showing in the block editor.\n *\n * @return {Object} Object of which block tools will be shown.\n */\nexport function useShowBlockTools() {\n\treturn useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetFirstMultiSelectedBlockClientId,\n\t\t\tgetBlock,\n\t\t\tgetBlockMode,\n\t\t\tgetSettings,\n\t\t\t__unstableGetEditorMode,\n\t\t\tisTyping,\n\t\t} = unlock( select( blockEditorStore ) );\n\n\t\tconst clientId =\n\t\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\t\tconst block = getBlock( clientId );\n\t\tconst editorMode = __unstableGetEditorMode();\n\t\tconst hasSelectedBlock = !! clientId && !! block;\n\t\tconst isEmptyDefaultBlock =\n\t\t\thasSelectedBlock &&\n\t\t\tisUnmodifiedDefaultBlock( block ) &&\n\t\t\tgetBlockMode( clientId ) !== 'html';\n\t\tconst _showEmptyBlockSideInserter =\n\t\t\tclientId &&\n\t\t\t! isTyping() &&\n\t\t\t// Hide the block inserter on the navigation mode.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/66636#discussion_r1824728483.\n\t\t\teditorMode !== 'navigation' &&\n\t\t\tisEmptyDefaultBlock;\n\t\tconst _showBlockToolbarPopover =\n\t\t\t! getSettings().hasFixedToolbar &&\n\t\t\t! _showEmptyBlockSideInserter &&\n\t\t\thasSelectedBlock &&\n\t\t\t! isEmptyDefaultBlock;\n\n\t\treturn {\n\t\t\tshowEmptyBlockSideInserter: _showEmptyBlockSideInserter,\n\t\t\tshowBlockToolbarPopover: _showBlockToolbarPopover,\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASI,iBAAiBA,CAAA,EAAG;EACnC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MACLC,wBAAwB;MACxBC,kCAAkC;MAClCC,QAAQ;MACRC,YAAY;MACZC,WAAW;MACXC,uBAAuB;MACvBC;IACD,CAAC,GAAG,IAAAC,kBAAM,EAAER,MAAM,CAAES,YAAiB,CAAE,CAAC;IAExC,MAAMC,QAAQ,GACbT,wBAAwB,CAAC,CAAC,IAAIC,kCAAkC,CAAC,CAAC;IAEnE,MAAMS,KAAK,GAAGR,QAAQ,CAAEO,QAAS,CAAC;IAClC,MAAME,UAAU,GAAGN,uBAAuB,CAAC,CAAC;IAC5C,MAAMO,gBAAgB,GAAG,CAAC,CAAEH,QAAQ,IAAI,CAAC,CAAEC,KAAK;IAChD,MAAMG,mBAAmB,GACxBD,gBAAgB,IAChB,IAAAE,gCAAwB,EAAEJ,KAAM,CAAC,IACjCP,YAAY,CAAEM,QAAS,CAAC,KAAK,MAAM;IACpC,MAAMM,2BAA2B,GAChCN,QAAQ,IACR,CAAEH,QAAQ,CAAC,CAAC;IACZ;IACA;IACAK,UAAU,KAAK,YAAY,IAC3BE,mBAAmB;IACpB,MAAMG,wBAAwB,GAC7B,CAAEZ,WAAW,CAAC,CAAC,CAACa,eAAe,IAC/B,CAAEF,2BAA2B,IAC7BH,gBAAgB,IAChB,CAAEC,mBAAmB;IAEtB,OAAO;MACNK,0BAA0B,EAAEH,2BAA2B;MACvDI,uBAAuB,EAAEH;IAC1B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
@@ -118,22 +118,34 @@ function splitStyleValue(value) {
|
|
|
118
118
|
}
|
|
119
119
|
return value;
|
|
120
120
|
}
|
|
121
|
-
function splitGapValue(value) {
|
|
121
|
+
function splitGapValue(value, isAxialGap) {
|
|
122
|
+
if (!value) {
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
|
|
122
126
|
// Check for shorthand value (a string value).
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
if (typeof value === 'string') {
|
|
128
|
+
/*
|
|
129
|
+
* Map the string value to appropriate sides for the spacing control depending
|
|
130
|
+
* on whether the current block has axial gap support or not.
|
|
131
|
+
*
|
|
132
|
+
* Note: The axial value pairs must match for the spacing control to display
|
|
133
|
+
* the appropriate horizontal/vertical sliders.
|
|
134
|
+
*/
|
|
135
|
+
return isAxialGap ? {
|
|
136
|
+
top: value,
|
|
137
|
+
right: value,
|
|
138
|
+
bottom: value,
|
|
139
|
+
left: value
|
|
140
|
+
} : {
|
|
126
141
|
top: value
|
|
127
142
|
};
|
|
128
143
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
144
|
+
return {
|
|
145
|
+
...value,
|
|
146
|
+
right: value?.left,
|
|
147
|
+
bottom: value?.top
|
|
148
|
+
};
|
|
137
149
|
}
|
|
138
150
|
function DimensionsToolsPanel({
|
|
139
151
|
resetAllFilter,
|
|
@@ -259,10 +271,10 @@ function DimensionsPanel({
|
|
|
259
271
|
|
|
260
272
|
// Block Gap
|
|
261
273
|
const showGapControl = useHasGap(settings);
|
|
262
|
-
const gapValue = decodeValue(inheritedValue?.spacing?.blockGap);
|
|
263
|
-
const gapValues = splitGapValue(gapValue);
|
|
264
274
|
const gapSides = Array.isArray(settings?.spacing?.blockGap) ? settings?.spacing?.blockGap : settings?.spacing?.blockGap?.sides;
|
|
265
275
|
const isAxialGap = gapSides && gapSides.some(side => AXIAL_SIDES.includes(side));
|
|
276
|
+
const gapValue = decodeValue(inheritedValue?.spacing?.blockGap);
|
|
277
|
+
const gapValues = splitGapValue(gapValue, isAxialGap);
|
|
266
278
|
const setGapValue = newGapValue => {
|
|
267
279
|
onChange((0, _object.setImmutably)(value, ['spacing', 'blockGap'], newGapValue));
|
|
268
280
|
};
|