@wordpress/block-editor 12.8.1 → 12.9.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 +6 -0
- package/README.md +5 -12
- package/build/components/block-list/block-outline.native.js +4 -3
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/index.js +4 -3
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -5
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +3 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/color-style-selector/index.js +1 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +7 -4
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +10 -8
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/link-control/index.js +1 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +48 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +3 -3
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +14 -8
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-images.js +5 -4
- package/build/components/list-view/use-list-view-images.js.map +1 -1
- package/build/components/preview-options/index.js +3 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +74 -63
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/warning/index.js +1 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/auto-inserting-blocks.js +174 -0
- package/build/hooks/auto-inserting-blocks.js.map +1 -0
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +4 -3
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/index.js +4 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -5
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +3 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +1 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +8 -4
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +11 -8
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +48 -7
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +3 -3
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +14 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-images.js +5 -4
- package/build-module/components/list-view/use-list-view-images.js.map +1 -1
- package/build-module/components/preview-options/index.js +3 -1
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +74 -63
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/warning/index.js +2 -2
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/auto-inserting-blocks.js +167 -0
- package/build-module/hooks/auto-inserting-blocks.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-style/content-rtl.css +8 -7
- package/build-style/content.css +8 -7
- package/package.json +32 -32
- package/src/components/block-list/block-outline.native.js +5 -2
- package/src/components/block-list/content.scss +2 -3
- package/src/components/block-list/index.js +4 -3
- package/src/components/block-popover/inbetween.js +4 -3
- package/src/components/block-popover/index.js +3 -2
- package/src/components/button-block-appender/content.scss +8 -0
- package/src/components/color-style-selector/index.js +1 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +7 -2
- package/src/components/inserter/search-results.native.js +13 -9
- package/src/components/link-control/index.js +1 -5
- package/src/components/link-control/test/index.js +1 -0
- package/src/components/list-view/block-select-button.js +67 -15
- package/src/components/list-view/drop-indicator.js +4 -5
- package/src/components/list-view/index.js +19 -13
- package/src/components/list-view/use-list-view-images.js +8 -4
- package/src/components/observe-typing/README.md +2 -2
- package/src/components/preview-options/index.js +2 -0
- package/src/components/provider/index.js +8 -1
- package/src/components/use-block-commands/index.js +92 -88
- package/src/components/warning/index.js +2 -2
- package/src/hooks/auto-inserting-blocks.js +232 -0
- package/src/hooks/index.js +1 -0
- package/build/utils/pre-parse-patterns.js +0 -68
- package/build/utils/pre-parse-patterns.js.map +0 -1
- package/build-module/utils/pre-parse-patterns.js +0 -61
- package/build-module/utils/pre-parse-patterns.js.map +0 -1
- package/src/components/url-popover/test/__snapshots__/index.js.snap +0 -133
- package/src/components/url-popover/test/index.js +0 -75
- package/src/utils/pre-parse-patterns.js +0 -69
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 12.9.0 (2023-08-31)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Embed the `ObserveTyping` behavior within the `BlockList` component making to simplify instanciations of third-party block editors.
|
|
10
|
+
|
|
5
11
|
## 12.8.0 (2023-08-16)
|
|
6
12
|
|
|
7
13
|
## 12.7.0 (2023-08-10)
|
package/README.md
CHANGED
|
@@ -20,9 +20,7 @@ import {
|
|
|
20
20
|
BlockList,
|
|
21
21
|
BlockTools,
|
|
22
22
|
WritingFlow,
|
|
23
|
-
ObserveTyping,
|
|
24
23
|
} from '@wordpress/block-editor';
|
|
25
|
-
import { SlotFillProvider, Popover } from '@wordpress/components';
|
|
26
24
|
import { useState } from '@wordpress/element';
|
|
27
25
|
|
|
28
26
|
function MyEditorComponent() {
|
|
@@ -34,16 +32,11 @@ function MyEditorComponent() {
|
|
|
34
32
|
onInput={ ( blocks ) => updateBlocks( blocks ) }
|
|
35
33
|
onChange={ ( blocks ) => updateBlocks( blocks ) }
|
|
36
34
|
>
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</ObserveTyping>
|
|
43
|
-
</WritingFlow>
|
|
44
|
-
</BlockTools>
|
|
45
|
-
<Popover.Slot />
|
|
46
|
-
</SlotFillProvider>
|
|
35
|
+
<BlockTools>
|
|
36
|
+
<WritingFlow>
|
|
37
|
+
<BlockList />
|
|
38
|
+
</WritingFlow>
|
|
39
|
+
</BlockTools>
|
|
47
40
|
</BlockEditorProvider>
|
|
48
41
|
);
|
|
49
42
|
}
|
|
@@ -21,7 +21,7 @@ var _block = _interopRequireDefault(require("./block.scss"));
|
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const TEXT_BLOCKS_WITH_OUTLINE = ['core/missing'];
|
|
25
25
|
function BlockOutline({
|
|
26
26
|
blockCategory,
|
|
27
27
|
hasInnerBlocks,
|
|
@@ -29,12 +29,13 @@ function BlockOutline({
|
|
|
29
29
|
isSelected,
|
|
30
30
|
name
|
|
31
31
|
}) {
|
|
32
|
-
const textBlockWithOutline =
|
|
32
|
+
const textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes(name);
|
|
33
|
+
const socialBlockWithOutline = name.includes('core/social-link');
|
|
33
34
|
const hasBlockTextCategory = blockCategory === 'text' && !textBlockWithOutline;
|
|
34
35
|
const hasBlockMediaCategory = blockCategory === 'media' || blockCategory === 'embed' || !blockCategory;
|
|
35
36
|
const shouldShowCompactOutline = hasBlockMediaCategory && !hasInnerBlocks || textBlockWithOutline;
|
|
36
37
|
const styleSolidBorder = [_block.default.solidBorder, (0, _compose.usePreferredColorSchemeStyle)(_block.default.solidBorderColor, _block.default.solidBorderColorDark), shouldShowCompactOutline && _block.default.solidBorderCompact, hasBlockTextCategory && _block.default.solidBorderTextContent];
|
|
37
|
-
const shoudlShowOutline = isSelected && (hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && isRootList || textBlockWithOutline);
|
|
38
|
+
const shoudlShowOutline = isSelected && (hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && isRootList || socialBlockWithOutline || textBlockWithOutline);
|
|
38
39
|
return shoudlShowOutline && (0, _element.createElement)(_reactNative.View, {
|
|
39
40
|
pointerEvents: "box-none",
|
|
40
41
|
style: styleSolidBorder
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_compose","_block","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_compose","_block","_interopRequireDefault","TEXT_BLOCKS_WITH_OUTLINE","BlockOutline","blockCategory","hasInnerBlocks","isRootList","isSelected","name","textBlockWithOutline","includes","socialBlockWithOutline","hasBlockTextCategory","hasBlockMediaCategory","shouldShowCompactOutline","styleSolidBorder","styles","solidBorder","usePreferredColorSchemeStyle","solidBorderColor","solidBorderColorDark","solidBorderCompact","solidBorderTextContent","shoudlShowOutline","_element","createElement","View","pointerEvents","style","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/block-list/block-outline.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './block.scss';\n\nconst TEXT_BLOCKS_WITH_OUTLINE = [ 'core/missing' ];\n\nfunction BlockOutline( {\n\tblockCategory,\n\thasInnerBlocks,\n\tisRootList,\n\tisSelected,\n\tname,\n} ) {\n\tconst textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes( name );\n\tconst socialBlockWithOutline = name.includes( 'core/social-link' );\n\n\tconst hasBlockTextCategory =\n\t\tblockCategory === 'text' && ! textBlockWithOutline;\n\tconst hasBlockMediaCategory =\n\t\tblockCategory === 'media' ||\n\t\tblockCategory === 'embed' ||\n\t\t! blockCategory;\n\tconst shouldShowCompactOutline =\n\t\t( hasBlockMediaCategory && ! hasInnerBlocks ) || textBlockWithOutline;\n\n\tconst styleSolidBorder = [\n\t\tstyles.solidBorder,\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.solidBorderColor,\n\t\t\tstyles.solidBorderColorDark\n\t\t),\n\t\tshouldShowCompactOutline && styles.solidBorderCompact,\n\t\thasBlockTextCategory && styles.solidBorderTextContent,\n\t];\n\n\tconst shoudlShowOutline =\n\t\tisSelected &&\n\t\t( ( hasBlockTextCategory && hasInnerBlocks ) ||\n\t\t\t( ! hasBlockTextCategory && hasInnerBlocks ) ||\n\t\t\t( ! hasBlockTextCategory && isRootList ) ||\n\t\t\tsocialBlockWithOutline ||\n\t\t\ttextBlockWithOutline );\n\n\treturn (\n\t\tshoudlShowOutline && (\n\t\t\t<View pointerEvents=\"box-none\" style={ styleSolidBorder } />\n\t\t)\n\t);\n}\n\nexport default BlockOutline;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAMI,wBAAwB,GAAG,CAAE,cAAc,CAAE;AAEnD,SAASC,YAAYA,CAAE;EACtBC,aAAa;EACbC,cAAc;EACdC,UAAU;EACVC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,MAAMC,oBAAoB,GAAGP,wBAAwB,CAACQ,QAAQ,CAAEF,IAAK,CAAC;EACtE,MAAMG,sBAAsB,GAAGH,IAAI,CAACE,QAAQ,CAAE,kBAAmB,CAAC;EAElE,MAAME,oBAAoB,GACzBR,aAAa,KAAK,MAAM,IAAI,CAAEK,oBAAoB;EACnD,MAAMI,qBAAqB,GAC1BT,aAAa,KAAK,OAAO,IACzBA,aAAa,KAAK,OAAO,IACzB,CAAEA,aAAa;EAChB,MAAMU,wBAAwB,GAC3BD,qBAAqB,IAAI,CAAER,cAAc,IAAMI,oBAAoB;EAEtE,MAAMM,gBAAgB,GAAG,CACxBC,cAAM,CAACC,WAAW,EAClB,IAAAC,qCAA4B,EAC3BF,cAAM,CAACG,gBAAgB,EACvBH,cAAM,CAACI,oBACR,CAAC,EACDN,wBAAwB,IAAIE,cAAM,CAACK,kBAAkB,EACrDT,oBAAoB,IAAII,cAAM,CAACM,sBAAsB,CACrD;EAED,MAAMC,iBAAiB,GACtBhB,UAAU,KACNK,oBAAoB,IAAIP,cAAc,IACvC,CAAEO,oBAAoB,IAAIP,cAAgB,IAC1C,CAAEO,oBAAoB,IAAIN,UAAY,IACxCK,sBAAsB,IACtBF,oBAAoB,CAAE;EAExB,OACCc,iBAAiB,IAChB,IAAAC,QAAA,CAAAC,aAAA,EAAC5B,YAAA,CAAA6B,IAAI;IAACC,aAAa,EAAC,UAAU;IAACC,KAAK,EAAGb;EAAkB,CAAE,CAC3D;AAEH;AAAC,IAAAc,QAAA,GAEc1B,YAAY;AAAA2B,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -15,11 +15,11 @@ var _block = _interopRequireDefault(require("./block"));
|
|
|
15
15
|
var _blockListAppender = _interopRequireDefault(require("../block-list-appender"));
|
|
16
16
|
var _useInBetweenInserter = require("./use-in-between-inserter");
|
|
17
17
|
var _store = require("../../store");
|
|
18
|
-
var _preParsePatterns = require("../../utils/pre-parse-patterns");
|
|
19
18
|
var _layout = require("./layout");
|
|
20
19
|
var _blockSelectionClearer = require("../block-selection-clearer");
|
|
21
20
|
var _innerBlocks = require("../inner-blocks");
|
|
22
21
|
var _context = require("../block-edit/context");
|
|
22
|
+
var _observeTyping = require("../observe-typing");
|
|
23
23
|
/**
|
|
24
24
|
* External dependencies
|
|
25
25
|
*/
|
|
@@ -93,7 +93,7 @@ function Root({
|
|
|
93
93
|
});
|
|
94
94
|
}, []);
|
|
95
95
|
const innerBlocksProps = (0, _innerBlocks.useInnerBlocksProps)({
|
|
96
|
-
ref: (0, _compose.useMergeRefs)([(0, _blockSelectionClearer.useBlockSelectionClearer)(), (0, _useInBetweenInserter.useInBetweenInserter)(),
|
|
96
|
+
ref: (0, _compose.useMergeRefs)([(0, _blockSelectionClearer.useBlockSelectionClearer)(), (0, _useInBetweenInserter.useInBetweenInserter)(), (0, _observeTyping.useTypingObserver)()]),
|
|
97
97
|
className: (0, _classnames.default)('is-root-container', className, {
|
|
98
98
|
'is-outline-mode': isOutlineMode,
|
|
99
99
|
'is-focus-mode': isFocusMode && isLargeViewport,
|
|
@@ -106,10 +106,11 @@ function Root({
|
|
|
106
106
|
value: intersectionObserver
|
|
107
107
|
}, (0, _element.createElement)("div", {
|
|
108
108
|
...innerBlocksProps
|
|
109
|
+
}), (0, _element.createElement)("div", {
|
|
110
|
+
ref: setElement
|
|
109
111
|
})));
|
|
110
112
|
}
|
|
111
113
|
function BlockList(settings) {
|
|
112
|
-
(0, _preParsePatterns.usePreParsePatterns)();
|
|
113
114
|
return (0, _element.createElement)(_context.BlockEditContextProvider, {
|
|
114
115
|
value: _context.DEFAULT_BLOCK_EDIT_CONTEXT
|
|
115
116
|
}, (0, _element.createElement)(Root, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_data","_compose","_block","_blockListAppender","_useInBetweenInserter","_store","_preParsePatterns","_layout","_blockSelectionClearer","_innerBlocks","_context","elementContext","createContext","IntersectionObserver","exports","pendingBlockVisibilityUpdatesPerRegistry","WeakMap","Root","className","settings","element","setElement","useState","isLargeViewport","useViewportMatch","isOutlineMode","isFocusMode","editorMode","useSelect","select","getSettings","__unstableGetEditorMode","blockEditorStore","outlineMode","focusMode","registry","useRegistry","setBlockVisibility","useDispatch","delayedBlockVisibilityUpdates","useDebounce","useCallback","updates","get","forEach","id","isIntersecting","trailing","intersectionObserver","useMemo","Observer","window","entries","set","entry","clientId","target","getAttribute","push","innerBlocksProps","useInnerBlocksProps","ref","useMergeRefs","useBlockSelectionClearer","useInBetweenInserter","classnames","createElement","Provider","value","BlockList","usePreParsePatterns","BlockEditContextProvider","DEFAULT_BLOCK_EDIT_CONTEXT","__unstableElementContext","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","layout","defaultLayout","order","selectedBlocks","visibleBlocks","getBlockOrder","getSelectedBlockClientIds","__unstableGetVisibleBlocks","LayoutProvider","map","AsyncModeProvider","key","has","includes","default","length","tagName","BlockListItems","props"],"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAsyncModeProvider,\n\tuseSelect,\n\tuseDispatch,\n\tuseRegistry,\n} from '@wordpress/data';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\tuseDebounce,\n} from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseState,\n\tuseMemo,\n\tuseCallback,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { usePreParsePatterns } from '../../utils/pre-parse-patterns';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useInnerBlocksProps } from '../inner-blocks';\nimport {\n\tBlockEditContextProvider,\n\tDEFAULT_BLOCK_EDIT_CONTEXT,\n} from '../block-edit/context';\n\nconst elementContext = createContext();\n\nexport const IntersectionObserver = createContext();\nconst pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();\n\nfunction Root( { className, ...settings } ) {\n\tconst [ element, setElement ] = useState();\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, editorMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetEditorMode } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\teditorMode: __unstableGetEditorMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst registry = useRegistry();\n\tconst { setBlockVisibility } = useDispatch( blockEditorStore );\n\n\tconst delayedBlockVisibilityUpdates = useDebounce(\n\t\tuseCallback( () => {\n\t\t\tconst updates = {};\n\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t.get( registry )\n\t\t\t\t.forEach( ( [ id, isIntersecting ] ) => {\n\t\t\t\t\tupdates[ id ] = isIntersecting;\n\t\t\t\t} );\n\t\t\tsetBlockVisibility( updates );\n\t\t}, [ registry ] ),\n\t\t300,\n\t\t{\n\t\t\ttrailing: true,\n\t\t}\n\t);\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tif ( ! pendingBlockVisibilityUpdatesPerRegistry.get( registry ) ) {\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry.set( registry, [] );\n\t\t\t}\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t\t.get( registry )\n\t\t\t\t\t.push( [ clientId, entry.isIntersecting ] );\n\t\t\t}\n\t\t\tdelayedBlockVisibilityUpdates();\n\t\t} );\n\t}, [] );\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tref: useMergeRefs( [\n\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\tuseInBetweenInserter(),\n\t\t\t\tsetElement,\n\t\t\t] ),\n\t\t\tclassName: classnames( 'is-root-container', className, {\n\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t'is-navigate-mode': editorMode === 'navigation',\n\t\t\t} ),\n\t\t},\n\t\tsettings\n\t);\n\treturn (\n\t\t<elementContext.Provider value={ element }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</IntersectionObserver.Provider>\n\t\t</elementContext.Provider>\n\t);\n}\n\nexport default function BlockList( settings ) {\n\tusePreParsePatterns();\n\treturn (\n\t\t<BlockEditContextProvider value={ DEFAULT_BLOCK_EDIT_CONTEXT }>\n\t\t\t<Root { ...settings } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n\nBlockList.__unstableElementContext = elementContext;\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\tlayout = defaultLayout,\n} ) {\n\tconst { order, selectedBlocks, visibleBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetVisibleBlocks,\n\t\t\t} = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t\tvisibleBlocks: __unstableGetVisibleBlocks(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t{ order.map( ( clientId ) => (\n\t\t\t\t<AsyncModeProvider\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// Only provide data asynchronously if the block is\n\t\t\t\t\t\t// not visible and not selected.\n\t\t\t\t\t\t! visibleBlocks.has( clientId ) &&\n\t\t\t\t\t\t! selectedBlocks.includes( clientId )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t</AsyncModeProvider>\n\t\t\t) ) }\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t/>\n\t\t</LayoutProvider>\n\t);\n}\n\nexport function BlockListItems( props ) {\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<AsyncModeProvider value={ false }>\n\t\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"],"mappings":";;;;;;;;;AAmBA,IAAAA,QAAA,GAAAC,OAAA;AAhBA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AAeA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,kBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,sBAAA,GAAAX,OAAA;AACA,IAAAY,YAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;;AAcA,MAAMc,cAAc,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAE/B,MAAMC,oBAAoB,GAA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,CAAC,IAC/B,CAAE2B,cAAc,CAACU,QAAQ,CAAErC,QAAS;EACpC,GAED,IAAA3D,QAAA,CAAAsE,aAAA,EAAChE,MAAA,CAAA2F,OAAc;IACdjB,YAAY,EAAGA,YAAc;IAC7BrB,QAAQ,EAAGA;EAAU,CACrB,CACiB,CAClB,CAAC,EACD0B,KAAK,CAACa,MAAM,GAAG,CAAC,IAAInB,WAAW,EACjC,IAAA/E,QAAA,CAAAsE,aAAA,EAAC/D,kBAAA,CAAA0F,OAAiB;IACjBE,OAAO,EAAGjB,6BAA+B;IACzCF,YAAY,EAAGA,YAAc;IAC7BC,cAAc,EAAGA;EAAgB,CACjC,CACc,CAAC;AAEnB;AAEO,SAASmB,cAAcA,CAAEC,KAAK,EAAG;EACvC;EACA;EACA,OACC,IAAArG,QAAA,CAAAsE,aAAA,EAAClE,KAAA,CAAAyF,iBAAiB;IAACrB,KAAK,EAAG;EAAO,GACjC,IAAAxE,QAAA,CAAAsE,aAAA,EAACQ,KAAK;IAAA,GAAMuB;EAAK,CAAI,CACH,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_data","_compose","_block","_blockListAppender","_useInBetweenInserter","_store","_layout","_blockSelectionClearer","_innerBlocks","_context","_observeTyping","elementContext","createContext","IntersectionObserver","exports","pendingBlockVisibilityUpdatesPerRegistry","WeakMap","Root","className","settings","element","setElement","useState","isLargeViewport","useViewportMatch","isOutlineMode","isFocusMode","editorMode","useSelect","select","getSettings","__unstableGetEditorMode","blockEditorStore","outlineMode","focusMode","registry","useRegistry","setBlockVisibility","useDispatch","delayedBlockVisibilityUpdates","useDebounce","useCallback","updates","get","forEach","id","isIntersecting","trailing","intersectionObserver","useMemo","Observer","window","entries","set","entry","clientId","target","getAttribute","push","innerBlocksProps","useInnerBlocksProps","ref","useMergeRefs","useBlockSelectionClearer","useInBetweenInserter","useTypingObserver","classnames","createElement","Provider","value","BlockList","BlockEditContextProvider","DEFAULT_BLOCK_EDIT_CONTEXT","__unstableElementContext","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","layout","defaultLayout","order","selectedBlocks","visibleBlocks","getBlockOrder","getSelectedBlockClientIds","__unstableGetVisibleBlocks","LayoutProvider","map","AsyncModeProvider","key","has","includes","default","length","tagName","BlockListItems","props"],"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAsyncModeProvider,\n\tuseSelect,\n\tuseDispatch,\n\tuseRegistry,\n} from '@wordpress/data';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\tuseDebounce,\n} from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseState,\n\tuseMemo,\n\tuseCallback,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useInnerBlocksProps } from '../inner-blocks';\nimport {\n\tBlockEditContextProvider,\n\tDEFAULT_BLOCK_EDIT_CONTEXT,\n} from '../block-edit/context';\nimport { useTypingObserver } from '../observe-typing';\n\nconst elementContext = createContext();\n\nexport const IntersectionObserver = createContext();\nconst pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();\n\nfunction Root( { className, ...settings } ) {\n\tconst [ element, setElement ] = useState();\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, editorMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetEditorMode } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\teditorMode: __unstableGetEditorMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst registry = useRegistry();\n\tconst { setBlockVisibility } = useDispatch( blockEditorStore );\n\n\tconst delayedBlockVisibilityUpdates = useDebounce(\n\t\tuseCallback( () => {\n\t\t\tconst updates = {};\n\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t.get( registry )\n\t\t\t\t.forEach( ( [ id, isIntersecting ] ) => {\n\t\t\t\t\tupdates[ id ] = isIntersecting;\n\t\t\t\t} );\n\t\t\tsetBlockVisibility( updates );\n\t\t}, [ registry ] ),\n\t\t300,\n\t\t{\n\t\t\ttrailing: true,\n\t\t}\n\t);\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tif ( ! pendingBlockVisibilityUpdatesPerRegistry.get( registry ) ) {\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry.set( registry, [] );\n\t\t\t}\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t\t.get( registry )\n\t\t\t\t\t.push( [ clientId, entry.isIntersecting ] );\n\t\t\t}\n\t\t\tdelayedBlockVisibilityUpdates();\n\t\t} );\n\t}, [] );\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tref: useMergeRefs( [\n\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\tuseInBetweenInserter(),\n\t\t\t\tuseTypingObserver(),\n\t\t\t] ),\n\t\t\tclassName: classnames( 'is-root-container', className, {\n\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t'is-navigate-mode': editorMode === 'navigation',\n\t\t\t} ),\n\t\t},\n\t\tsettings\n\t);\n\treturn (\n\t\t<elementContext.Provider value={ element }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t{ /* Ensure element and layout styles are always at the end of the document */ }\n\t\t\t\t<div ref={ setElement } />\n\t\t\t</IntersectionObserver.Provider>\n\t\t</elementContext.Provider>\n\t);\n}\n\nexport default function BlockList( settings ) {\n\treturn (\n\t\t<BlockEditContextProvider value={ DEFAULT_BLOCK_EDIT_CONTEXT }>\n\t\t\t<Root { ...settings } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n\nBlockList.__unstableElementContext = elementContext;\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\tlayout = defaultLayout,\n} ) {\n\tconst { order, selectedBlocks, visibleBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetVisibleBlocks,\n\t\t\t} = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t\tvisibleBlocks: __unstableGetVisibleBlocks(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t{ order.map( ( clientId ) => (\n\t\t\t\t<AsyncModeProvider\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// Only provide data asynchronously if the block is\n\t\t\t\t\t\t// not visible and not selected.\n\t\t\t\t\t\t! visibleBlocks.has( clientId ) &&\n\t\t\t\t\t\t! selectedBlocks.includes( clientId )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t</AsyncModeProvider>\n\t\t\t) ) }\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t/>\n\t\t</LayoutProvider>\n\t);\n}\n\nexport function BlockListItems( props ) {\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<AsyncModeProvider value={ false }>\n\t\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"],"mappings":";;;;;;;;;AAmBA,IAAAA,QAAA,GAAAC,OAAA;AAhBA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AAeA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,kBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,sBAAA,GAAAV,OAAA;AACA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AAIA,IAAAa,cAAA,GAAAb,OAAA;AAxCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;;AAcA,MAAMc,cAAc,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAE/B,MAAMC,oBAAoB,GAAG,IAAAD,sBAAa,EAAC,CAAC;AAACE,OAAA,CAAAD,oBAAA,GAAAA,oBAAA;AACpD,MAAME,wCAAwC,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE9D,SAASC,IAAIA,CAAE;EAAEC,SAAS;EAAE,GAAGC;AAAS,CAAC,EAAG;EAC3C,MAAM,CAAEC,OAAO,EAAEC,UAAU,CAAE,GAAG,IAAAC,iBAAQ,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ClB,CAAC,EACD0B,KAAK,CAACa,MAAM,GAAG,CAAC,IAAInB,WAAW,EACjC,IAAA/E,QAAA,CAAAuE,aAAA,EAAChE,kBAAA,CAAA0F,OAAiB;IACjBE,OAAO,EAAGjB,6BAA+B;IACzCF,YAAY,EAAGA,YAAc;IAC7BC,cAAc,EAAGA;EAAgB,CACjC,CACc,CAAC;AAEnB;AAEO,SAASmB,cAAcA,CAAEC,KAAK,EAAG;EACvC;EACA;EACA,OACC,IAAArG,QAAA,CAAAuE,aAAA,EAACnE,KAAA,CAAAyF,iBAAiB;IAACpB,KAAK,EAAG;EAAO,GACjC,IAAAzE,QAAA,CAAAuE,aAAA,EAACO,KAAK;IAAA,GAAMuB;EAAK,CAAI,CACH,CAAC;AAEtB"}
|
|
@@ -68,11 +68,9 @@ function BlockPopoverInbetween({
|
|
|
68
68
|
popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
|
|
69
69
|
return undefined;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
ownerDocument
|
|
73
|
-
} = previousElement || nextElement;
|
|
71
|
+
const contextElement = previousElement || nextElement;
|
|
74
72
|
return {
|
|
75
|
-
|
|
73
|
+
contextElement,
|
|
76
74
|
getBoundingClientRect() {
|
|
77
75
|
const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
|
|
78
76
|
const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
|
|
@@ -169,7 +167,8 @@ function BlockPopoverInbetween({
|
|
|
169
167
|
// Render in the old slot if needed for backward compatibility,
|
|
170
168
|
// otherwise render in place (not in the default popover slot).
|
|
171
169
|
,
|
|
172
|
-
__unstableSlotName: __unstablePopoverSlot
|
|
170
|
+
__unstableSlotName: __unstablePopoverSlot,
|
|
171
|
+
inline: !__unstablePopoverSlot
|
|
173
172
|
// Forces a remount of the popover when its position changes
|
|
174
173
|
// This makes sure the popover doesn't animate from its previous position.
|
|
175
174
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_data","_components","_i18n","_store","_useBlockRefs","_usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","createContext","exports","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","useReducer","s","orientation","rootClientId","isVisible","useSelect","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","useBlockElement","nextElement","isVertical","popoverAnchor","useMemo","undefined","ownerDocument","getBoundingClientRect","previousRect","nextRect","left","top","width","height","bottom","isRTL","right","window","DOMRect","popoverScrollRef","usePopoverScroll","useLayoutEffect","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","createElement","Popover","ref","animate","anchor","focusOnMount","__unstableSlotName","key","className","classnames","resize","flip","placement","variant","_default","default"],"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth = previousRect ? previousRect.width : nextRect.width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAOA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAN,sBAAA,CAAAF,OAAA;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAKA,MAAMS,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAEtD,MAAMC,qBAAqB,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAACC,OAAA,CAAAF,qBAAA,GAAAA,qBAAA;AAErD,SAASG,qBAAqBA,CAAE;EAC/BC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC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,MAAM;MACZa,eAAe,CAACO,aAAa,CAACqB,WAAW,EAAEE,mBAAmB,CAC7D,QAAQ,EACR3C,qBACD,CAAC;IACF,CAAC;EACF,CAAC,EAAE,CAAEa,eAAe,CAAG,CAAC;;EAExB;EACA;EACA;EACA,IAAO,CAAEA,eAAe,IAAI,CAAEE,WAAW,IAAM,CAAEV,SAAS,EAAG;IAC5D,OAAO,IAAI;EACZ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OACC,IAAA7B,QAAA,CAAAoE,aAAA,EAAC/D,WAAA,CAAAgE,OAAO;IACPC,GAAG,EAAGb,gBAAkB;IACxBc,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAG/B,aAAe;IACxBgC,YAAY,EAAG;IACf;IACA;IAAA;IACAC,kBAAkB,EAAGtD,qBAAqB,IAAI;IAC9C;IACA;IAAA;IACAuD,GAAG,EAAGzD,YAAY,GAAG,IAAI,GAAGU,YAAc;IAAA,GACrCN,KAAK;IACVsD,SAAS,EAAG,IAAAC,mBAAU,EACrB,4BAA4B,EAC5B,uCAAuC,EACvCvD,KAAK,CAACsD,SACP,CAAG;IACHE,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdC,SAAS,EAAC,SAAS;IACnBC,OAAO,EAAC;EAAU,GAElB,IAAAjF,QAAA,CAAAoE,aAAA;IAAKQ,SAAS,EAAC;EAAiD,GAC7DzD,QACE,CACG,CAAC;EAEX;AACD;AAAC,IAAA+D,QAAA,GAEclE,qBAAqB;AAAAD,OAAA,CAAAoE,OAAA,GAAAD,QAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_data","_components","_i18n","_store","_useBlockRefs","_usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","createContext","exports","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","useReducer","s","orientation","rootClientId","isVisible","useSelect","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","useBlockElement","nextElement","isVertical","popoverAnchor","useMemo","undefined","contextElement","getBoundingClientRect","previousRect","nextRect","left","top","width","height","bottom","isRTL","right","window","DOMRect","popoverScrollRef","usePopoverScroll","useLayoutEffect","observer","MutationObserver","observe","attributes","disconnect","ownerDocument","defaultView","addEventListener","removeEventListener","createElement","Popover","ref","animate","anchor","focusOnMount","__unstableSlotName","inline","key","className","classnames","resize","flip","placement","variant","_default","default"],"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst contextElement = previousElement || nextElement;\n\n\t\treturn {\n\t\t\tcontextElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth = previousRect ? previousRect.width : nextRect.width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAOA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAN,sBAAA,CAAAF,OAAA;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAKA,MAAMS,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAEtD,MAAMC,qBAAqB,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAACC,OAAA,CAAAF,qBAAA,GAAAA,qBAAA;AAErD,SAASG,qBAAqBA,CAAE;EAC/BC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,qBAAqB;EACrBC,oBAAoB;EACpB,GAAGC;AACJ,CAAC,EAAG;EACH;EACA,MAAM,CAAEC,uBAAuB,EAAEC,qBAAqB,CAAE,GAAG,IAAAC,mBAAU;EACpE;EACEC,CAAC,IAAM,CAAEA,CAAC,GAAG,CAAC,IAAKhB,6BAA6B,EAClD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M,CAAEV,SAAS,EAAG;IAC5D,OAAO,IAAI;EACZ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OACC,IAAA7B,QAAA,CAAAqE,aAAA,EAAChE,WAAA,CAAAiE,OAAO;IACPC,GAAG,EAAGd,gBAAkB;IACxBe,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAGhC,aAAe;IACxBiC,YAAY,EAAG;IACf;IACA;IAAA;IACAC,kBAAkB,EAAGvD,qBAAuB;IAC5CwD,MAAM,EAAG,CAAExD;IACX;IACA;IAAA;IACAyD,GAAG,EAAG3D,YAAY,GAAG,IAAI,GAAGU,YAAc;IAAA,GACrCN,KAAK;IACVwD,SAAS,EAAG,IAAAC,mBAAU,EACrB,4BAA4B,EAC5B,uCAAuC,EACvCzD,KAAK,CAACwD,SACP,CAAG;IACHE,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdC,SAAS,EAAC,SAAS;IACnBC,OAAO,EAAC;EAAU,GAElB,IAAAnF,QAAA,CAAAqE,aAAA;IAAKS,SAAS,EAAC;EAAiD,GAC7D3D,QACE,CACG,CAAC;EAEX;AACD;AAAC,IAAAiE,QAAA,GAEcpE,qBAAqB;AAAAD,OAAA,CAAAsE,OAAA,GAAAD,QAAA"}
|
|
@@ -101,7 +101,7 @@ function BlockPopover({
|
|
|
101
101
|
const height = bottom - top;
|
|
102
102
|
return new window.DOMRect(left, top, width, height);
|
|
103
103
|
},
|
|
104
|
-
|
|
104
|
+
contextElement: selectedElement
|
|
105
105
|
};
|
|
106
106
|
}, [bottomClientId, lastSelectedElement, selectedElement, popoverDimensionsRecomputeCounter]);
|
|
107
107
|
if (!selectedElement || bottomClientId && !lastSelectedElement) {
|
|
@@ -115,7 +115,8 @@ function BlockPopover({
|
|
|
115
115
|
// Render in the old slot if needed for backward compatibility,
|
|
116
116
|
// otherwise render in place (not in the default popover slot).
|
|
117
117
|
,
|
|
118
|
-
__unstableSlotName: __unstablePopoverSlot
|
|
118
|
+
__unstableSlotName: __unstablePopoverSlot,
|
|
119
|
+
inline: !__unstablePopoverSlot,
|
|
119
120
|
placement: "top-start",
|
|
120
121
|
resize: false,
|
|
121
122
|
flip: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_components","_useBlockRefs","_usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","useBlockElement","lastSelectedElement","mergedRefs","useMergeRefs","usePopoverScroll","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","useReducer","s","useLayoutEffect","observer","window","MutationObserver","observe","attributes","disconnect","style","useMemo","position","width","offsetWidth","height","offsetHeight","popoverAnchor","undefined","getBoundingClientRect","_lastSelectedBCR$left","_lastSelectedBCR$top","_lastSelectedBCR$righ","_lastSelectedBCR$bott","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","createElement","Popover","animate","focusOnMount","anchor","__unstableSlotName","placement","resize","flip","className","classnames","variant","_default","forwardRef","exports","default"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst style = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\tlastSelectedElement !== selectedElement\n\t\t) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [\n\t\tselectedElement,\n\t\tlastSelectedElement,\n\t\t__unstableRefreshSize,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAWA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA,MAAMO,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAE7D,SAASC,YAAYA,CACpB;EACCC,QAAQ;EACRC,cAAc;EACdC,QAAQ;EACRC,qBAAqB;EACrBC,qBAAqB,GAAG,KAAK;EAC7BC,qBAAqB;EACrBC,oBAAoB;EACpBC,KAAK,GAAG,IAAI;EACZ,GAAGC;AACJ,CAAC,EACDC,GAAG,EACF;EACD,MAAMC,eAAe,GAAG,IAAA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MACDoB,aAAa,EAAE1C,eAAe,CAAC0C;IAChC,CAAC;EACF,CAAC,EAAE,CACFnD,cAAc,EACdW,mBAAmB,EACnBF,eAAe,EACfM,iCAAiC,CAChC,CAAC;EAEH,IAAK,CAAEN,eAAe,IAAMT,cAAc,IAAI,CAAEW,mBAAqB,EAAG;IACvE,OAAO,IAAI;EACZ;EAEA,OACC,IAAAxB,QAAA,CAAAiE,aAAA,EAAC5D,WAAA,CAAA6D,OAAO;IACP7C,GAAG,EAAGI,UAAY;IAClB0C,OAAO,EAAG,KAAO;IACjBC,YAAY,EAAG,KAAO;IACtBC,MAAM,EAAGvB;IACT;IACA;IAAA;IACAwB,kBAAkB,EAAGrD,qBAAqB,IAAI,IAAM;IACpDsD,SAAS,EAAC,WAAW;IACrBC,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdtD,KAAK,EAAGA,KAAO;IAAA,GACVC,KAAK;IACVsD,SAAS,EAAG,IAAAC,mBAAU,EACrB,4BAA4B,EAC5BvD,KAAK,CAACsD,SACP,CAAG;IACHE,OAAO,EAAC;EAAU,GAEhB5D,qBAAqB,IAAI,IAAAhB,QAAA,CAAAiE,aAAA;IAAK1B,KAAK,EAAGA;EAAO,GAAGzB,QAAe,CAAC,EAChE,CAAEE,qBAAqB,IAAIF,QACrB,CAAC;AAEZ;AAAC,IAAA+D,QAAA,GAEc,IAAAC,mBAAU,EAAEnE,YAAa,CAAC;AAAAoE,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_components","_useBlockRefs","_usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","useBlockElement","lastSelectedElement","mergedRefs","useMergeRefs","usePopoverScroll","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","useReducer","s","useLayoutEffect","observer","window","MutationObserver","observe","attributes","disconnect","style","useMemo","position","width","offsetWidth","height","offsetHeight","popoverAnchor","undefined","getBoundingClientRect","_lastSelectedBCR$left","_lastSelectedBCR$top","_lastSelectedBCR$righ","_lastSelectedBCR$bott","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","contextElement","createElement","Popover","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","classnames","variant","_default","forwardRef","exports","default"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst style = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\tlastSelectedElement !== selectedElement\n\t\t) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [\n\t\tselectedElement,\n\t\tlastSelectedElement,\n\t\t__unstableRefreshSize,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\tcontextElement: selectedElement,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAWA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA,MAAMO,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAE7D,SAASC,YAAYA,CACpB;EACCC,QAAQ;EACRC,cAAc;EACdC,QAAQ;EACRC,qBAAqB;EACrBC,qBAAqB,GAAG,KAAK;EAC7BC,qBAAqB;EACrBC,oBAAoB;EACpBC,KAAK,GAAG,IAAI;EACZ,GAAGC;AACJ,CAAC,EACDC,GAAG,EACF;EACD,MAAMC,eAAe,GAAG,IAAAC,uCAAe,EAAEX,QAAS,CAAC;EACnD,MAAMY,mBAAmB,GAAG,IAAAD,uCAAe,EAAEV,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAID,QAAS,CAAC;EACzE,MAAMa,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAChCL,GAAG,EACH,IAAAM,yBAAgB,EAAET,oBAAqB,CAAC,CACvC,CAAC;EAEH,MAAM,CACLU,iCAAiC,EACjCC,+BAA+B,CAC/B,GAAG,IAAAC,mBAAU;EACb;EACEC,CAAC,IAAM,CAAEA,CAAC,GAAG,CAAC,IAAKvB,6BAA6B,EAClD,CACD,CAAC;;EAED;EACA;EACA;EACA;EACA;E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AuB;IAC5CsD,MAAM,EAAG,CAAEtD,qBAAuB;IAClCuD,SAAS,EAAC,WAAW;IACrBC,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdvD,KAAK,EAAGA,KAAO;IAAA,GACVC,KAAK;IACVuD,SAAS,EAAG,IAAAC,mBAAU,EACrB,4BAA4B,EAC5BxD,KAAK,CAACuD,SACP,CAAG;IACHE,OAAO,EAAC;EAAU,GAEhB7D,qBAAqB,IAAI,IAAAhB,QAAA,CAAAiE,aAAA;IAAK1B,KAAK,EAAGA;EAAO,GAAGzB,QAAe,CAAC,EAChE,CAAEE,qBAAqB,IAAIF,QACrB,CAAC;AAEZ;AAAC,IAAAgE,QAAA,GAEc,IAAAC,mBAAU,EAAEpE,YAAa,CAAC;AAAAqE,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
|
|
@@ -15,7 +15,7 @@ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
const ColorSelectorSVGIcon = () => (0, _element.createElement)(_components.SVG, {
|
|
18
|
-
xmlns: "
|
|
18
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
19
19
|
viewBox: "0 0 20 20"
|
|
20
20
|
}, (0, _element.createElement)(_components.Path, {
|
|
21
21
|
d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_keycodes","_deprecated","_interopRequireDefault","ColorSelectorSVGIcon","_element","createElement","SVG","xmlns","viewBox","Path","d","ColorSelectorIcon","style","className","renderToggleComponent","TextColor","BackgroundColor","onToggle","isOpen","openOnArrowDown","event","keyCode","DOWN","preventDefault","ToolbarGroup","ToolbarButton","label","__","onClick","onKeyDown","icon","BlockColorsStyleSelector","children","other","deprecated","alternative","since","version","Dropdown","popoverProps","placement","contentClassName","renderToggle","renderContent","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/color-style-selector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\tDropdown,\n\tToolbarGroup,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport deprecated from '@wordpress/deprecated';\n\nconst ColorSelectorSVGIcon = () => (\n\t<SVG xmlns=\"
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_keycodes","_deprecated","_interopRequireDefault","ColorSelectorSVGIcon","_element","createElement","SVG","xmlns","viewBox","Path","d","ColorSelectorIcon","style","className","renderToggleComponent","TextColor","BackgroundColor","onToggle","isOpen","openOnArrowDown","event","keyCode","DOWN","preventDefault","ToolbarGroup","ToolbarButton","label","__","onClick","onKeyDown","icon","BlockColorsStyleSelector","children","other","deprecated","alternative","since","version","Dropdown","popoverProps","placement","contentClassName","renderToggle","renderContent","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/color-style-selector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\tDropdown,\n\tToolbarGroup,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport deprecated from '@wordpress/deprecated';\n\nconst ColorSelectorSVGIcon = () => (\n\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n\t\t<Path d=\"M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z\" />\n\t</SVG>\n);\n\n/**\n * Color Selector Icon component.\n *\n * @param {Object} props Component properties.\n * @param {Object} props.style Style object.\n * @param {string} props.className Class name for component.\n *\n * @return {*} React Icon component.\n */\nconst ColorSelectorIcon = ( { style, className } ) => {\n\treturn (\n\t\t<div className=\"block-library-colors-selector__icon-container\">\n\t\t\t<div\n\t\t\t\tclassName={ `${ className } block-library-colors-selector__state-selection` }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t<ColorSelectorSVGIcon />\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\n/**\n * Renders the Colors Selector Toolbar with the icon button.\n *\n * @param {Object} props Component properties.\n * @param {Object} props.TextColor Text color component that wraps icon.\n * @param {Object} props.BackgroundColor Background color component that wraps icon.\n *\n * @return {*} React toggle button component.\n */\nconst renderToggleComponent =\n\t( { TextColor, BackgroundColor } ) =>\n\t( { onToggle, isOpen } ) => {\n\t\tconst openOnArrowDown = ( event ) => {\n\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonToggle();\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"components-toolbar__control block-library-colors-selector__toggle\"\n\t\t\t\t\tlabel={ __( 'Open Colors Selector' ) }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\ticon={\n\t\t\t\t\t\t<BackgroundColor>\n\t\t\t\t\t\t\t<TextColor>\n\t\t\t\t\t\t\t\t<ColorSelectorIcon />\n\t\t\t\t\t\t\t</TextColor>\n\t\t\t\t\t\t</BackgroundColor>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t};\n\nconst BlockColorsStyleSelector = ( { children, ...other } ) => {\n\tdeprecated( `wp.blockEditor.BlockColorsStyleSelector`, {\n\t\talternative: 'block supports API',\n\t\tsince: '6.1',\n\t\tversion: '6.3',\n\t} );\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\tclassName=\"block-library-colors-selector\"\n\t\t\tcontentClassName=\"block-library-colors-selector__popover\"\n\t\t\trenderToggle={ renderToggleComponent( other ) }\n\t\t\trenderContent={ () => children }\n\t\t/>\n\t);\n};\n\nexport default BlockColorsStyleSelector;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAZA;AACA;AACA;;AAYA,MAAMK,oBAAoB,GAAGA,CAAA,KAC5B,IAAAC,QAAA,CAAAC,aAAA,EAACR,WAAA,CAAAS,GAAG;EAACC,KAAK,EAAC,4BAA4B;EAACC,OAAO,EAAC;AAAW,GAC1D,IAAAJ,QAAA,CAAAC,aAAA,EAACR,WAAA,CAAAY,IAAI;EAACC,CAAC,EAAC;AAA6e,CAAE,CACnf,CACL;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGA,CAAE;EAAEC,KAAK;EA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B;IACjCC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;EAEH,OACC,IAAAjC,QAAA,CAAAC,aAAA,EAACR,WAAA,CAAAyC,QAAQ;IACRC,YAAY,EAAG;MAAEC,SAAS,EAAE;IAAe,CAAG;IAC9C3B,SAAS,EAAC,+BAA+B;IACzC4B,gBAAgB,EAAC,wCAAwC;IACzDC,YAAY,EAAG5B,qBAAqB,CAAEmB,KAAM,CAAG;IAC/CU,aAAa,EAAGA,CAAA,KAAMX;EAAU,CAChC,CAAC;AAEJ,CAAC;AAAC,IAAAY,QAAA,GAEab,wBAAwB;AAAAc,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -25,18 +25,21 @@ function ReusableBlocksTab({
|
|
|
25
25
|
listProps
|
|
26
26
|
}) {
|
|
27
27
|
const {
|
|
28
|
-
|
|
28
|
+
inserterItems
|
|
29
29
|
} = (0, _data.useSelect)(select => {
|
|
30
30
|
const {
|
|
31
31
|
getInserterItems
|
|
32
32
|
} = select(_store.store);
|
|
33
33
|
const allItems = getInserterItems(rootClientId);
|
|
34
34
|
return {
|
|
35
|
-
|
|
36
|
-
onlyReusable: true
|
|
37
|
-
})
|
|
35
|
+
inserterItems: allItems
|
|
38
36
|
};
|
|
39
37
|
}, [rootClientId]);
|
|
38
|
+
const items = (0, _element.useMemo)(() => {
|
|
39
|
+
return (0, _utils.filterInserterItems)(inserterItems, {
|
|
40
|
+
onlyReusable: true
|
|
41
|
+
});
|
|
42
|
+
}, [inserterItems]);
|
|
40
43
|
const sections = [(0, _utils.createInserterSection)({
|
|
41
44
|
key: 'reuseable',
|
|
42
45
|
items
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_i18n","_blockTypesList","_interopRequireDefault","_store","_utils","ReusableBlocksTab","onSelect","rootClientId","listProps","inserterItems","useSelect","select","getInserterItems","blockEditorStore","allItems","items","useMemo","filterInserterItems","onlyReusable","sections","createInserterSection","key","createElement","default","name","label","__","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport { store as blockEditorStore } from '../../store';\nimport { createInserterSection, filterInserterItems } from './utils';\n\nfunction ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {\n\tconst { inserterItems } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getInserterItems } = select( blockEditorStore );\n\t\t\tconst allItems = getInserterItems( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tinserterItems: allItems,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst items = useMemo( () => {\n\t\treturn filterInserterItems( inserterItems, { onlyReusable: true } );\n\t}, [ inserterItems ] );\n\n\tconst sections = [ createInserterSection( { key: 'reuseable', items } ) ];\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"SyncedPatterns\"\n\t\t\tsections={ sections }\n\t\t\tonSelect={ onSelect }\n\t\t\tlistProps={ listProps }\n\t\t\tlabel={ __( 'Synced patterns' ) }\n\t\t/>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"],"mappings":";;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAFA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAMA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA,SAASO,iBAAiBA,CAAE;EAAEC,QAAQ;EAAEC,YAAY;EAAEC;AAAU,CAAC,EAAG;EACnE,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,eAAS,EAChCC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAiB,CAAC,GAAGD,MAAM,CAAEE,YAAiB,CAAC;IACvD,MAAMC,QAAQ,GAAGF,gBAAgB,CAAEL,YAAa,CAAC;IAEjD,OAAO;MACNE,aAAa,EAAEK;IAChB,CAAC;EACF,CAAC,EACD,CAAEP,YAAY,CACf,CAAC;EAED,MAAMQ,KAAK,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC5B,OAAO,IAAAC,0BAAmB,EAAER,aAAa,EAAE;MAAES,YAAY,EAAE;IAAK,CAAE,CAAC;EACpE,CAAC,EAAE,CAAET,aAAa,CAAG,CAAC;EAEtB,MAAMU,QAAQ,GAAG,CAAE,IAAAC,4BAAqB,EAAE;IAAEC,GAAG,EAAE,WAAW;IAAEN;EAAM,CAAE,CAAC,CAAE;EAEzE,OACC,IAAAlB,QAAA,CAAAyB,aAAA,EAACrB,eAAA,CAAAsB,OAAc;IACdC,IAAI,EAAC,gBAAgB;IACrBL,QAAQ,EAAGA,QAAU;IACrBb,QAAQ,EAAGA,QAAU;IACrBE,SAAS,EAAGA,SAAW;IACvBiB,KAAK,EAAG,IAAAC,QAAE,EAAE,iBAAkB;EAAG,CACjC,CAAC;AAEJ;AAAC,IAAAC,QAAA,GAEctB,iBAAiB;AAAAuB,OAAA,CAAAL,OAAA,GAAAI,QAAA"}
|
|
@@ -30,17 +30,19 @@ function InserterSearchResults({
|
|
|
30
30
|
isFullScreen
|
|
31
31
|
}) {
|
|
32
32
|
const {
|
|
33
|
-
|
|
33
|
+
inserterItems
|
|
34
34
|
} = (0, _data.useSelect)(select => {
|
|
35
|
-
const
|
|
36
|
-
const availableItems = (0, _utils.filterInserterItems)(allItems, {
|
|
37
|
-
allowReusable: true
|
|
38
|
-
});
|
|
39
|
-
const filteredItems = (0, _searchItems.searchItems)(availableItems, filterValue);
|
|
35
|
+
const items = select(_store.store).getInserterItems(rootClientId);
|
|
40
36
|
return {
|
|
41
|
-
|
|
37
|
+
inserterItems: items
|
|
42
38
|
};
|
|
43
|
-
}, [rootClientId
|
|
39
|
+
}, [rootClientId]);
|
|
40
|
+
const blockTypes = (0, _element.useMemo)(() => {
|
|
41
|
+
const availableItems = (0, _utils.filterInserterItems)(inserterItems, {
|
|
42
|
+
allowReusable: true
|
|
43
|
+
});
|
|
44
|
+
return (0, _searchItems.searchItems)(availableItems, filterValue);
|
|
45
|
+
}, [inserterItems, filterValue]);
|
|
44
46
|
const {
|
|
45
47
|
items,
|
|
46
48
|
trackBlockTypeSelected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_i18n","_searchItems","_blockTypesList","_interopRequireDefault","_noResults","_store","_useBlockTypeImpressions","_utils","InserterSearchResults","filterValue","onSelect","listProps","rootClientId","isFullScreen","inserterItems","useSelect","select","items","blockEditorStore","getInserterItems","blockTypes","useMemo","availableItems","filterInserterItems","allowReusable","searchItems","trackBlockTypeSelected","useBlockTypeImpressions","length","createElement","default","handleSelect","args","name","initialNumToRender","sections","createInserterSection","key","label","__","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/search-results.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchItems } from './search-items';\nimport BlockTypesList from '../block-types-list';\nimport InserterNoResults from './no-results';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockTypeImpressions from './hooks/use-block-type-impressions';\nimport { createInserterSection, filterInserterItems } from './utils';\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tlistProps,\n\trootClientId,\n\tisFullScreen,\n} ) {\n\tconst { inserterItems } = useSelect(\n\t\t( select ) => {\n\t\t\tconst items =\n\t\t\t\tselect( blockEditorStore ).getInserterItems( rootClientId );\n\n\t\t\treturn { inserterItems: items };\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst blockTypes = useMemo( () => {\n\t\tconst availableItems = filterInserterItems( inserterItems, {\n\t\t\tallowReusable: true,\n\t\t} );\n\n\t\treturn searchItems( availableItems, filterValue );\n\t}, [ inserterItems, filterValue ] );\n\n\tconst { items, trackBlockTypeSelected } =\n\t\tuseBlockTypeImpressions( blockTypes );\n\n\tif ( ! items || items?.length === 0 ) {\n\t\treturn <InserterNoResults />;\n\t}\n\n\tconst handleSelect = ( ...args ) => {\n\t\ttrackBlockTypeSelected( ...args );\n\t\tonSelect( ...args );\n\t};\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"Blocks\"\n\t\t\tinitialNumToRender={ isFullScreen ? 10 : 3 }\n\t\t\tsections={ [ createInserterSection( { key: 'search', items } ) ] }\n\t\t\tonSelect={ handleSelect }\n\t\t\tlistProps={ listProps }\n\t\t\tlabel={ __( 'Blocks' ) }\n\t\t/>\n\t);\n}\n\nexport default InserterSearchResults;\n"],"mappings":";;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAFA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,wBAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAfA;AACA;AACA;;AAKA;AACA;AACA;;AAQA,SAASU,qBAAqBA,CAAE;EAC/BC,WAAW;EACXC,QAAQ;EACRC,SAAS;EACTC,YAAY;EACZC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,eAAS,EAChCC,MAAM,IAAM;IACb,MAAMC,KAAK,GACVD,MAAM,CAAEE,YAAiB,CAAC,CAACC,gBAAgB,CAAEP,YAAa,CAA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