@wordpress/block-editor 10.1.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-controls/slot.js +2 -2
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -5
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +4 -4
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-parent-selector/index.js +2 -2
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +3 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +20 -17
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +6 -3
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +2 -2
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/search-items.js +2 -17
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inspector-controls/slot.js +2 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/rich-text/index.js +17 -0
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +10 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +5 -4
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +1 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +19 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +62 -20
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +14 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/index.js +13 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +76 -23
- package/build/hooks/layout.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/reducer.js +5 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-controls/slot.js +3 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +4 -4
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +2 -2
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +3 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +20 -17
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +6 -3
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +2 -2
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -17
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +3 -2
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/rich-text/index.js +17 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +10 -3
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +6 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +19 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +62 -21
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +14 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +73 -23
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/reducer.js +5 -4
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +48 -23
- package/build-style/style.css +48 -23
- package/package.json +29 -30
- package/src/components/block-controls/slot.js +3 -3
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-draggable/test/index.native.js +0 -9
- package/src/components/block-inspector/index.js +6 -10
- package/src/components/block-list/use-in-between-inserter.js +5 -5
- package/src/components/block-parent-selector/index.js +2 -2
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +37 -22
- package/src/components/block-preview/style.scss +13 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -7
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +104 -33
- package/src/components/block-switcher/test/index.js +121 -61
- package/src/components/block-tools/index.js +1 -1
- package/src/components/block-tools/use-block-toolbar-popover-props.js +6 -0
- package/src/components/button-block-appender/style.scss +3 -1
- package/src/components/image-editor/use-transform-image.js +2 -2
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +3 -3
- package/src/components/inserter/search-items.js +3 -15
- package/src/components/inserter/test/search-items.js +4 -0
- package/src/components/inspector-controls/slot.js +6 -2
- package/src/components/responsive-block-control/test/index.js +73 -118
- package/src/components/rich-text/index.js +22 -0
- package/src/components/spacing-sizes-control/index.js +15 -3
- package/src/components/spacing-sizes-control/spacing-input-control.js +8 -7
- package/src/components/spacing-sizes-control/style.scss +28 -24
- package/src/components/url-popover/image-url-input-ui.js +1 -1
- package/src/components/use-block-drop-zone/index.js +26 -1
- package/src/components/use-on-block-drop/index.js +110 -35
- package/src/components/use-on-block-drop/test/index.js +33 -43
- package/src/components/writing-flow/use-arrow-nav.js +12 -8
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +64 -21
- package/src/index.js +2 -0
- package/src/store/reducer.js +4 -4
- package/src/store/selectors.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -29,8 +29,8 @@ function BlockControlsSlot(_ref) {
|
|
|
29
29
|
} = _ref;
|
|
30
30
|
const accessibleToolbarState = (0, _element.useContext)(_components.__experimentalToolbarContext);
|
|
31
31
|
const Slot = _groups.default[group].Slot;
|
|
32
|
-
const
|
|
33
|
-
const hasFills = Boolean(
|
|
32
|
+
const fills = (0, _components.__experimentalUseSlotFills)(Slot.__unstableName);
|
|
33
|
+
const hasFills = Boolean(fills && fills.length);
|
|
34
34
|
|
|
35
35
|
if (!hasFills) {
|
|
36
36
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-controls/slot.js"],"names":["BlockControlsSlot","group","props","accessibleToolbarState","ToolbarContext","Slot","groups","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-controls/slot.js"],"names":["BlockControlsSlot","group","props","accessibleToolbarState","ToolbarContext","Slot","groups","fills","__unstableName","hasFills","Boolean","length"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AASA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,iBAAT,OAA8D;AAAA,MAAlC;AAAEC,IAAAA,KAAK,GAAG,SAAV;AAAqB,OAAGC;AAAxB,GAAkC;AAC5E,QAAMC,sBAAsB,GAAG,yBAAYC,wCAAZ,CAA/B;AACA,QAAMC,IAAI,GAAGC,gBAAQL,KAAR,EAAgBI,IAA7B;AACA,QAAME,KAAK,GAAG,4CAAcF,IAAI,CAACG,cAAnB,CAAd;AACA,QAAMC,QAAQ,GAAGC,OAAO,CAAEH,KAAK,IAAIA,KAAK,CAACI,MAAjB,CAAxB;;AAEA,MAAK,CAAEF,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,MAAKR,KAAK,KAAK,SAAf,EAA2B;AAC1B,WACC,4BAAC,IAAD,6BACMC,KADN;AAEC,MAAA,gBAAgB,MAFjB;AAGC,MAAA,SAAS,EAAGC;AAHb,OADD;AAOA;;AAED,SACC,4BAAC,wBAAD,QACC,4BAAC,IAAD,6BACMD,KADN;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,SAAS,EAAGC;AAHb,KADD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport {\n\t__experimentalToolbarContext as ToolbarContext,\n\tToolbarGroup,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\n\nexport default function BlockControlsSlot( { group = 'default', ...props } ) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\tconst Slot = groups[ group ].Slot;\n\tconst fills = useSlotFills( Slot.__unstableName );\n\tconst hasFills = Boolean( fills && fills.length );\n\n\tif ( ! hasFills ) {\n\t\treturn null;\n\t}\n\n\tif ( group === 'default' ) {\n\t\treturn (\n\t\t\t<Slot\n\t\t\t\t{ ...props }\n\t\t\t\tbubblesVirtually\n\t\t\t\tfillProps={ accessibleToolbarState }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<Slot\n\t\t\t\t{ ...props }\n\t\t\t\tbubblesVirtually\n\t\t\t\tfillProps={ accessibleToolbarState }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","blockEditorStore","rootClientId","blockName","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","transferData","type","srcClientIds","event","length","onDraggableStart","onDraggableEnd"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","blockEditorStore","rootClientId","blockName","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","event","length","onDraggableStart","onDraggableEnd"],"mappings":";;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,cAAc,GAAG,QAMhB;AAAA,MANkB;AACxBC,IAAAA,QADwB;AAExBC,IAAAA,SAF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IAAAA;AAHoB,GAArB;AAMA,SACC,4BAAC,qBAAD;AACC,IAAA,cAAc,EAAGH,cADlB;AAEC,IAAA,8BAA8B,EAAC,WAFhC;AAGC,IAAA,YAAY,EAAGqB,YAHhB;AAIC,IAAA,WAAW,EAAKG,KAAF,IAAa;AAC1BP,MAAAA,mBAAmB,CAAElB,SAAF,CAAnB;AACAc,MAAAA,UAAU,CAACM,OAAX,GAAqB,IAArB;AAEAL,MAAAA,cAAc,CAAEU,KAAF,CAAd;;AAEA,UAAKvB,WAAL,EAAmB;AAClBA,QAAAA,WAAW;AACX;AACD,KAbF;AAcC,IAAA,UAAU,EAAGc,gBAdd;AAeC,IAAA,SAAS,EAAG,MAAM;AACjBG,MAAAA,kBAAkB;AAClBL,MAAAA,UAAU,CAACM,OAAX,GAAqB,KAArB;AAEAH,MAAAA,aAAa;;AAEb,UAAKd,SAAL,EAAiB;AAChBA,QAAAA,SAAS;AACT;AACD,KAxBF;AAyBC,IAAA,2BAA2B,EAC1B,4BAAC,sBAAD;AAAoB,MAAA,KAAK,EAAGH,SAAS,CAAC0B,MAAtC;AAA+C,MAAA,IAAI,EAAGpB;AAAtD;AA1BF,KA6BG,SAA4C;AAAA,QAA1C;AAAEqB,MAAAA,gBAAF;AAAoBC,MAAAA;AAApB,KAA0C;AAC7C,WAAO7B,QAAQ,CAAE;AAChBsB,MAAAA,SAAS,EAAE,IADK;AAEhBnB,MAAAA,WAAW,EAAEyB,gBAFG;AAGhBxB,MAAAA,SAAS,EAAEyB;AAHK,KAAF,CAAf;AAKA,GAnCF,CADD;AAuCA,CAvFD;;eAyFe9B,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n} ) => {\n\tconst { srcRootClientId, isDraggable, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canMoveBlocks, getBlockRootClientId, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: getBlockType( blockName )?.icon,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\tisDragging.current = true;\n\n\t\t\t\tstartScrolling( event );\n\n\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\tonDragStart();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip count={ clientIds.length } icon={ icon } />\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"]}
|
|
@@ -161,8 +161,7 @@ const BlockInspector = _ref5 => {
|
|
|
161
161
|
getSelectedBlockClientId,
|
|
162
162
|
getSelectedBlockCount,
|
|
163
163
|
getBlockName,
|
|
164
|
-
__unstableGetContentLockingParent
|
|
165
|
-
getTemplateLock
|
|
164
|
+
__unstableGetContentLockingParent
|
|
166
165
|
} = select(_store.store);
|
|
167
166
|
|
|
168
167
|
const _selectedBlockClientId = getSelectedBlockClientId();
|
|
@@ -176,7 +175,7 @@ const BlockInspector = _ref5 => {
|
|
|
176
175
|
selectedBlockClientId: _selectedBlockClientId,
|
|
177
176
|
selectedBlockName: _selectedBlockName,
|
|
178
177
|
blockType: _blockType,
|
|
179
|
-
topLevelLockedBlock:
|
|
178
|
+
topLevelLockedBlock: __unstableGetContentLockingParent(_selectedBlockClientId)
|
|
180
179
|
};
|
|
181
180
|
}, []);
|
|
182
181
|
|
|
@@ -270,8 +269,8 @@ const BlockInspectorSingleBlock = _ref6 => {
|
|
|
270
269
|
};
|
|
271
270
|
|
|
272
271
|
const AdvancedControls = () => {
|
|
273
|
-
const
|
|
274
|
-
const hasFills = Boolean(
|
|
272
|
+
const fills = (0, _components.__experimentalUseSlotFills)(_inspectorControls.InspectorAdvancedControls.slotName);
|
|
273
|
+
const hasFills = Boolean(fills && fills.length);
|
|
275
274
|
|
|
276
275
|
if (!hasFills) {
|
|
277
276
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-inspector/index.js"],"names":["useContentBlocks","blockTypes","block","contenBlocksObjectAux","reduce","result","blockType","Object","entries","attributes","some","__experimentalRole","name","isContentBlock","blockName","getContentBlocks","blocks","push","innerBlocks","BlockNavigationButton","selectedBlock","selectBlock","blockEditorStore","find","isSelected","clientId","icon","title","BlockInspectorLockedBlocks","topLevelLockedBlock","select","blocksStore","getBlockTypes","getBlock","getSelectedBlock","blockInformation","contentBlocks","map","contentBlock","BlockInspector","showNoBlockSelectedMessage","count","selectedBlockName","selectedBlockClientId","getSelectedBlockClientId","getSelectedBlockCount","getBlockName","__unstableGetContentLockingParent","getTemplateLock","_selectedBlockClientId","_selectedBlockName","_blockType","isSelectedBlockUnregistered","BlockInspectorSingleBlock","hasBlockStyles","getBlockStyles","blockStyles","length","AdvancedControls","slot","InspectorAdvancedControls","slotName","hasFills","Boolean","fills"],"mappings":";;;;;;;;;AAmBA;;AAhBA;;AACA;;AAMA;;AAQA;;AAMA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AApCA;AACA;AACA;;AAmBA;AACA;AACA;AAeA,SAASA,gBAAT,CAA2BC,UAA3B,EAAuCC,KAAvC,EAA+C;AAC9C,QAAMC,qBAAqB,GAAG,sBAAS,MAAM;AAC5C,WAAOF,UAAU,CAACG,MAAX,CAAmB,CAAEC,MAAF,EAAUC,SAAV,KAAyB;AAClD,UACCC,MAAM,CAACC,OAAP,CAAgBF,SAAS,CAACG,UAA1B,EAAuCC,IAAvC,CACC;AAAA,YAAE,GAAI;AAAEC,UAAAA;AAAF,SAAJ,CAAF;AAAA,eACCA,kBAAkB,KAAK,SADxB;AAAA,OADD,CADD,EAKE;AACDN,QAAAA,MAAM,CAAEC,SAAS,CAACM,I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AC,4BAAD;AAAqB,IAAA,GAAG,EAAC;AAAzB,IAvCD,CADD;AA2CA,CArDD;;AAuDA,MAAM4C,gBAAgB,GAAG,MAAM;AAC9B,QAAMC,IAAI,GAAG,uCAASC,6CAA0BC,QAAnC,CAAb;AACA,QAAMC,QAAQ,GAAGC,OAAO,CAAEJ,IAAI,CAACK,KAAL,IAAcL,IAAI,CAACK,KAAL,CAAWP,MAA3B,CAAxB;;AAEA,MAAK,CAAEK,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,KAAK,EAAG,cAAI,UAAJ,CAFT;AAGC,IAAA,WAAW,EAAG;AAHf,KAKC,4BAAC,0BAAD,CAAmB,IAAnB;AAAwB,IAAA,mBAAmB,EAAC;AAA5C,IALD,CADD;AASA,CAjBD;AAmBA;AACA;AACA;;;eACevB,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetUnregisteredTypeHandlerName,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\tPanelBody,\n\t__experimentalUseSlot as useSlot,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SkipToSelectedBlock from '../skip-to-selected-block';\nimport BlockCard from '../block-card';\nimport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from '../inspector-controls';\nimport BlockStyles from '../block-styles';\nimport MultiSelectionInspector from '../multi-selection-inspector';\nimport DefaultStylePicker from '../default-style-picker';\nimport BlockVariationTransforms from '../block-variation-transforms';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\n\nfunction useContentBlocks( blockTypes, block ) {\n\tconst contenBlocksObjectAux = useMemo( () => {\n\t\treturn blockTypes.reduce( ( result, blockType ) => {\n\t\t\tif (\n\t\t\t\tObject.entries( blockType.attributes ).some(\n\t\t\t\t\t( [ , { __experimentalRole } ] ) =>\n\t\t\t\t\t\t__experimentalRole === 'content'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tresult[ blockType.name ] = true;\n\t\t\t}\n\t\t\treturn result;\n\t\t}, {} );\n\t}, [ blockTypes ] );\n\tconst isContentBlock = useCallback(\n\t\t( blockName ) => {\n\t\t\treturn !! contenBlocksObjectAux[ blockName ];\n\t\t},\n\t\t[ blockTypes ]\n\t);\n\treturn useMemo( () => {\n\t\treturn getContentBlocks( [ block ], isContentBlock );\n\t}, [ block, isContentBlock ] );\n}\n\nfunction getContentBlocks( blocks, isContentBlock ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( isContentBlock( block.name ) ) {\n\t\t\tresult.push( block );\n\t\t}\n\t\tresult.push( ...getContentBlocks( block.innerBlocks, isContentBlock ) );\n\t}\n\treturn result;\n}\n\nfunction BlockNavigationButton( { blockTypes, block, selectedBlock } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst blockType = blockTypes.find( ( { name } ) => name === block.name );\n\tconst isSelected =\n\t\tselectedBlock && selectedBlock.clientId === block.clientId;\n\treturn (\n\t\t<Button\n\t\t\tisPressed={ isSelected }\n\t\t\tonClick={ () => selectBlock( block.clientId ) }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<BlockIcon icon={ blockType.icon } />\n\t\t\t\t<FlexItem>{ blockType.title }</FlexItem>\n\t\t\t</HStack>\n\t\t</Button>\n\t);\n}\n\nfunction BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {\n\tconst { blockTypes, block, selectedBlock } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tblockTypes: select( blocksStore ).getBlockTypes(),\n\t\t\t\tblock: select( blockEditorStore ).getBlock(\n\t\t\t\t\ttopLevelLockedBlock\n\t\t\t\t),\n\t\t\t\tselectedBlock: select( blockEditorStore ).getSelectedBlock(),\n\t\t\t};\n\t\t},\n\t\t[ topLevelLockedBlock ]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( topLevelLockedBlock );\n\tconst contentBlocks = useContentBlocks( blockTypes, block );\n\treturn (\n\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t<BlockCard { ...blockInformation } />\n\t\t\t<BlockVariationTransforms blockClientId={ topLevelLockedBlock } />\n\t\t\t<VStack\n\t\t\t\tspacing={ 1 }\n\t\t\t\tpadding={ 4 }\n\t\t\t\tclassName=\"block-editor-block-inspector__block-buttons-container\"\n\t\t\t>\n\t\t\t\t<h2 className=\"block-editor-block-card__title\">\n\t\t\t\t\t{ __( 'Content' ) }\n\t\t\t\t</h2>\n\t\t\t\t{ contentBlocks.map( ( contentBlock ) => (\n\t\t\t\t\t<BlockNavigationButton\n\t\t\t\t\t\tselectedBlock={ selectedBlock }\n\t\t\t\t\t\tkey={ contentBlock.clientId }\n\t\t\t\t\t\tblock={ contentBlock }\n\t\t\t\t\t\tblockTypes={ blockTypes }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nconst BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {\n\tconst {\n\t\tcount,\n\t\tselectedBlockName,\n\t\tselectedBlockClientId,\n\t\tblockType,\n\t\ttopLevelLockedBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetSelectedBlockCount,\n\t\t\tgetBlockName,\n\t\t\t__unstableGetContentLockingParent,\n\t\t\tgetTemplateLock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\t\tconst _selectedBlockName =\n\t\t\t_selectedBlockClientId && getBlockName( _selectedBlockClientId );\n\t\tconst _blockType =\n\t\t\t_selectedBlockName && getBlockType( _selectedBlockName );\n\n\t\treturn {\n\t\t\tcount: getSelectedBlockCount(),\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tselectedBlockName: _selectedBlockName,\n\t\t\tblockType: _blockType,\n\t\t\ttopLevelLockedBlock:\n\t\t\t\tgetTemplateLock( _selectedBlockClientId ) === 'contentOnly'\n\t\t\t\t\t? _selectedBlockClientId\n\t\t\t\t\t: __unstableGetContentLockingParent(\n\t\t\t\t\t\t\t_selectedBlockClientId\n\t\t\t\t\t ),\n\t\t};\n\t}, [] );\n\n\tif ( count > 1 ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t\t<MultiSelectionInspector />\n\t\t\t\t<InspectorControls.Slot />\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"color\"\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t\t/>\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"typography\"\n\t\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t\t/>\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"dimensions\"\n\t\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t\t/>\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"border\"\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst isSelectedBlockUnregistered =\n\t\tselectedBlockName === getUnregisteredTypeHandlerName();\n\n\t/*\n\t * If the selected block is of an unregistered type, avoid showing it as an actual selection\n\t * because we want the user to focus on the unregistered block warning, not block settings.\n\t */\n\tif (\n\t\t! blockType ||\n\t\t! selectedBlockClientId ||\n\t\tisSelectedBlockUnregistered\n\t) {\n\t\tif ( showNoBlockSelectedMessage ) {\n\t\t\treturn (\n\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t</span>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n\tif ( topLevelLockedBlock ) {\n\t\treturn (\n\t\t\t<BlockInspectorLockedBlocks\n\t\t\t\ttopLevelLockedBlock={ topLevelLockedBlock }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<BlockInspectorSingleBlock\n\t\t\tclientId={ selectedBlockClientId }\n\t\t\tblockName={ blockType.name }\n\t\t/>\n\t);\n};\n\nconst BlockInspectorSingleBlock = ( { clientId, blockName } ) => {\n\tconst hasBlockStyles = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\tconst blockStyles = getBlockStyles( blockName );\n\t\t\treturn blockStyles && blockStyles.length > 0;\n\t\t},\n\t\t[ blockName ]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\treturn (\n\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t<BlockCard { ...blockInformation } />\n\t\t\t<BlockVariationTransforms blockClientId={ clientId } />\n\t\t\t{ hasBlockStyles && (\n\t\t\t\t<div>\n\t\t\t\t\t<PanelBody title={ __( 'Styles' ) }>\n\t\t\t\t\t\t<BlockStyles\n\t\t\t\t\t\t\tscope=\"core/block-inspector\"\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ hasBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'defaultStylePicker',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) && <DefaultStylePicker blockName={ blockName } /> }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<InspectorControls.Slot />\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"border\"\n\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t/>\n\t\t\t<div>\n\t\t\t\t<AdvancedControls />\n\t\t\t</div>\n\t\t\t<SkipToSelectedBlock key=\"back\" />\n\t\t</div>\n\t);\n};\n\nconst AdvancedControls = () => {\n\tconst slot = useSlot( InspectorAdvancedControls.slotName );\n\tconst hasFills = Boolean( slot.fills && slot.fills.length );\n\n\tif ( ! hasFills ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\tclassName=\"block-editor-block-inspector__advanced\"\n\t\t\ttitle={ __( 'Advanced' ) }\n\t\t\tinitialOpen={ false }\n\t\t>\n\t\t\t<InspectorControls.Slot __experimentalGroup=\"advanced\" />\n\t\t</PanelBody>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md\n */\nexport default BlockInspector;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-inspector/index.js"],"names":["useContentBlocks","blockTypes","block","contenBlocksObjectAux","reduce","result","blockType","Object","entries","attributes","some","__experimentalRole","name","isContentBlock","blockName","getContentBlocks","blocks","push","innerBlocks","BlockNavigationButton","selectedBlock","selectBlock","blockEditorStore","find","isSelected","clientId","icon","title","BlockInspectorLockedBlocks","topLevelLockedBlock","select","blocksStore","getBlockTypes","getBlock","getSelectedBlock","blockInformation","contentBlocks","map","contentBlock","BlockInspector","showNoBlockSelectedMessage","count","selectedBlockName","selectedBlockClientId","getSelectedBlockClientId","getSelectedBlockCount","getBlockName","__unstableGetContentLockingParent","_selectedBlockClientId","_selectedBlockName","_blockType","isSelectedBlockUnregistered","BlockInspectorSingleBlock","hasBlockStyles","getBlockStyles","blockStyles","length","AdvancedControls","fills","InspectorAdvancedControls","slotName","hasFills","Boolean"],"mappings":";;;;;;;;;AAmBA;;AAhBA;;AACA;;AAMA;;AAQA;;AAMA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AApCA;AACA;AACA;;AAmBA;AACA;AACA;AAeA,SAASA,gBAAT,CAA2BC,UAA3B,EAAuCC,KAAvC,EAA+C;AAC9C,QAAMC,qBAAqB,GAAG,sBAAS,MAAM;AAC5C,WAAOF,UAAU,CAACG,MAAX,CAAmB,CAAEC,MAAF,EAAUC,SAAV,KAAyB;AAClD,UACCC,MAAM,CAACC,OAAP,CAAgBF,SAAS,CAACG,UAA1B,EAAuCC,IAAvC,CACC;AAAA,YAAE,GAAI;AAAEC,UAAAA;AAAF,SAAJ,CAAF;AAAA,eACCA,kBAAkB,KAAK,SADxB;AAAA,OADD,CADD,EAKE;AACDN,QAAAA,MAAM,CAAEC,SAAS,CAACM,IAAZ,CAAN,GAA2B,IAA3B;AACA;;AACD,aAAOP,MAAP;AACA,KAVM,EAUJ,EAVI,CAAP;AAWA,GAZ6B,EAY3B,CAAEJ,UAAF,CAZ2B,CAA9B;AAaA,QAAMY,cAAc,GAAG,0BACpBC,SAAF,IAAiB;AAChB,WAAO,CAAC,CAAEX,qBAAqB,CAAEW,SAAF,CAA/B;AACA,GAHqB,EAItB,CAAEb,UAAF,CAJsB,CAAvB;AAMA,SAAO,sBAAS,MAAM;AACrB,WAAOc,gBAAgB,CAAE,CAAEb,KAAF,CAAF,EAAaW,cAAb,CAAvB;AACA,GAFM,EAEJ,CAAEX,KAAF,EAASW,cAAT,CAFI,CAAP;AAGA;;AAED,SAASE,gBAAT,CAA2BC,MAA3B,EAAmCH,cAAnC,EAAoD;AACnD,QAAMR,MA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ordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetUnregisteredTypeHandlerName,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\tPanelBody,\n\t__experimentalUseSlotFills as useSlotFills,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SkipToSelectedBlock from '../skip-to-selected-block';\nimport BlockCard from '../block-card';\nimport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from '../inspector-controls';\nimport BlockStyles from '../block-styles';\nimport MultiSelectionInspector from '../multi-selection-inspector';\nimport DefaultStylePicker from '../default-style-picker';\nimport BlockVariationTransforms from '../block-variation-transforms';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\n\nfunction useContentBlocks( blockTypes, block ) {\n\tconst contenBlocksObjectAux = useMemo( () => {\n\t\treturn blockTypes.reduce( ( result, blockType ) => {\n\t\t\tif (\n\t\t\t\tObject.entries( blockType.attributes ).some(\n\t\t\t\t\t( [ , { __experimentalRole } ] ) =>\n\t\t\t\t\t\t__experimentalRole === 'content'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tresult[ blockType.name ] = true;\n\t\t\t}\n\t\t\treturn result;\n\t\t}, {} );\n\t}, [ blockTypes ] );\n\tconst isContentBlock = useCallback(\n\t\t( blockName ) => {\n\t\t\treturn !! contenBlocksObjectAux[ blockName ];\n\t\t},\n\t\t[ blockTypes ]\n\t);\n\treturn useMemo( () => {\n\t\treturn getContentBlocks( [ block ], isContentBlock );\n\t}, [ block, isContentBlock ] );\n}\n\nfunction getContentBlocks( blocks, isContentBlock ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( isContentBlock( block.name ) ) {\n\t\t\tresult.push( block );\n\t\t}\n\t\tresult.push( ...getContentBlocks( block.innerBlocks, isContentBlock ) );\n\t}\n\treturn result;\n}\n\nfunction BlockNavigationButton( { blockTypes, block, selectedBlock } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst blockType = blockTypes.find( ( { name } ) => name === block.name );\n\tconst isSelected =\n\t\tselectedBlock && selectedBlock.clientId === block.clientId;\n\treturn (\n\t\t<Button\n\t\t\tisPressed={ isSelected }\n\t\t\tonClick={ () => selectBlock( block.clientId ) }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<BlockIcon icon={ blockType.icon } />\n\t\t\t\t<FlexItem>{ blockType.title }</FlexItem>\n\t\t\t</HStack>\n\t\t</Button>\n\t);\n}\n\nfunction BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {\n\tconst { blockTypes, block, selectedBlock } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tblockTypes: select( blocksStore ).getBlockTypes(),\n\t\t\t\tblock: select( blockEditorStore ).getBlock(\n\t\t\t\t\ttopLevelLockedBlock\n\t\t\t\t),\n\t\t\t\tselectedBlock: select( blockEditorStore ).getSelectedBlock(),\n\t\t\t};\n\t\t},\n\t\t[ topLevelLockedBlock ]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( topLevelLockedBlock );\n\tconst contentBlocks = useContentBlocks( blockTypes, block );\n\treturn (\n\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t<BlockCard { ...blockInformation } />\n\t\t\t<BlockVariationTransforms blockClientId={ topLevelLockedBlock } />\n\t\t\t<VStack\n\t\t\t\tspacing={ 1 }\n\t\t\t\tpadding={ 4 }\n\t\t\t\tclassName=\"block-editor-block-inspector__block-buttons-container\"\n\t\t\t>\n\t\t\t\t<h2 className=\"block-editor-block-card__title\">\n\t\t\t\t\t{ __( 'Content' ) }\n\t\t\t\t</h2>\n\t\t\t\t{ contentBlocks.map( ( contentBlock ) => (\n\t\t\t\t\t<BlockNavigationButton\n\t\t\t\t\t\tselectedBlock={ selectedBlock }\n\t\t\t\t\t\tkey={ contentBlock.clientId }\n\t\t\t\t\t\tblock={ contentBlock }\n\t\t\t\t\t\tblockTypes={ blockTypes }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nconst BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {\n\tconst {\n\t\tcount,\n\t\tselectedBlockName,\n\t\tselectedBlockClientId,\n\t\tblockType,\n\t\ttopLevelLockedBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetSelectedBlockCount,\n\t\t\tgetBlockName,\n\t\t\t__unstableGetContentLockingParent,\n\t\t} = select( blockEditorStore );\n\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\t\tconst _selectedBlockName =\n\t\t\t_selectedBlockClientId && getBlockName( _selectedBlockClientId );\n\t\tconst _blockType =\n\t\t\t_selectedBlockName && getBlockType( _selectedBlockName );\n\n\t\treturn {\n\t\t\tcount: getSelectedBlockCount(),\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tselectedBlockName: _selectedBlockName,\n\t\t\tblockType: _blockType,\n\t\t\ttopLevelLockedBlock: __unstableGetContentLockingParent(\n\t\t\t\t_selectedBlockClientId\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tif ( count > 1 ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t\t<MultiSelectionInspector />\n\t\t\t\t<InspectorControls.Slot />\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"color\"\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t\t/>\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"typography\"\n\t\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t\t/>\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"dimensions\"\n\t\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t\t/>\n\t\t\t\t<InspectorControls.Slot\n\t\t\t\t\t__experimentalGroup=\"border\"\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst isSelectedBlockUnregistered =\n\t\tselectedBlockName === getUnregisteredTypeHandlerName();\n\n\t/*\n\t * If the selected block is of an unregistered type, avoid showing it as an actual selection\n\t * because we want the user to focus on the unregistered block warning, not block settings.\n\t */\n\tif (\n\t\t! blockType ||\n\t\t! selectedBlockClientId ||\n\t\tisSelectedBlockUnregistered\n\t) {\n\t\tif ( showNoBlockSelectedMessage ) {\n\t\t\treturn (\n\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t</span>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n\tif ( topLevelLockedBlock ) {\n\t\treturn (\n\t\t\t<BlockInspectorLockedBlocks\n\t\t\t\ttopLevelLockedBlock={ topLevelLockedBlock }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<BlockInspectorSingleBlock\n\t\t\tclientId={ selectedBlockClientId }\n\t\t\tblockName={ blockType.name }\n\t\t/>\n\t);\n};\n\nconst BlockInspectorSingleBlock = ( { clientId, blockName } ) => {\n\tconst hasBlockStyles = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\tconst blockStyles = getBlockStyles( blockName );\n\t\t\treturn blockStyles && blockStyles.length > 0;\n\t\t},\n\t\t[ blockName ]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\treturn (\n\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t<BlockCard { ...blockInformation } />\n\t\t\t<BlockVariationTransforms blockClientId={ clientId } />\n\t\t\t{ hasBlockStyles && (\n\t\t\t\t<div>\n\t\t\t\t\t<PanelBody title={ __( 'Styles' ) }>\n\t\t\t\t\t\t<BlockStyles\n\t\t\t\t\t\t\tscope=\"core/block-inspector\"\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ hasBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'defaultStylePicker',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) && <DefaultStylePicker blockName={ blockName } /> }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<InspectorControls.Slot />\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"border\"\n\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t/>\n\t\t\t<div>\n\t\t\t\t<AdvancedControls />\n\t\t\t</div>\n\t\t\t<SkipToSelectedBlock key=\"back\" />\n\t\t</div>\n\t);\n};\n\nconst AdvancedControls = () => {\n\tconst fills = useSlotFills( InspectorAdvancedControls.slotName );\n\tconst hasFills = Boolean( fills && fills.length );\n\n\tif ( ! hasFills ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\tclassName=\"block-editor-block-inspector__advanced\"\n\t\t\ttitle={ __( 'Advanced' ) }\n\t\t\tinitialOpen={ false }\n\t\t>\n\t\t\t<InspectorControls.Slot __experimentalGroup=\"advanced\" />\n\t\t</PanelBody>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md\n */\nexport default BlockInspector;\n"]}
|
|
@@ -81,12 +81,12 @@ function useInBetweenInserter() {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const offsetLeft = event.clientX - rect.left;
|
|
84
|
+
const offsetTop = event.clientY;
|
|
85
|
+
const offsetLeft = event.clientX;
|
|
87
86
|
const children = Array.from(event.target.children);
|
|
88
87
|
let element = children.find(blockEl => {
|
|
89
|
-
|
|
88
|
+
const blockElRect = blockEl.getBoundingClientRect();
|
|
89
|
+
return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockElRect.top > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockElRect.left > offsetLeft;
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
if (!element) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"names":["useInBetweenInserter","openRef","InsertionPointOpenRef","isInBetweenInserterDisabled","select","blockEditorStore","getSettings","hasReducedUI","__unstableGetEditorMode","getBlockListSettings","getBlockRootClientId","getBlockIndex","isBlockInsertionPointVisible","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","showInsertionPoint","hideInsertionPoint","delayedShowInsertionPoint","trailing","node","onMouseMove","event","current","target","classList","contains","cancel","rootClientId","blockElement","getAttribute","closest","orientation","rect","getBoundingClientRect","offsetTop","clientY","top","offsetLeft","clientX","left","children","Array","from","element","find","blockEl","id","firstElementChild","clientId","slice","length","includes","elementRect","bottom","right","index","__unstableWithInserter","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAC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CAA0B,WAA1B,EAAuCtC,WAAvC;AACA,KAFD;AAGA,GAnIK,EAoIN,CACCrB,OADD,EAECQ,oBAFD,EAGCC,oBAHD,EAICC,aAJD,EAKCC,4BALD,EAMCC,gBAND,EAOCI,kBAPD,EAQCC,kBARD,EASCJ,yBATD,EAUCX,2BAVD,CApIM,CAAP;AAiJA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useDebounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().hasReducedUI ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tisBlockInsertionPointVisible,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t} = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst delayedShowInsertionPoint = useDebounce( showInsertionPoint, 500, {\n\t\ttrailing: true,\n\t} );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\tif ( openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\t// Don't set the insertion point if the template is locked.\n\t\t\t\tif ( getTemplateLock( rootClientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst orientation =\n\t\t\t\t\tgetBlockListSettings( rootClientId )?.orientation ||\n\t\t\t\t\t'vertical';\n\t\t\t\tconst rect = event.target.getBoundingClientRect();\n\t\t\t\tconst offsetTop = event.clientY - rect.top;\n\t\t\t\tconst offsetLeft = event.clientX - rect.left;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockEl.offsetTop > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\tblockEl.offsetLeft > offsetLeft )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter when hovering above (conflicts with\n\t\t\t\t// block toolbar) or inside selected block(s).\n\t\t\t\tif ( getSelectedBlockClientIds().includes( clientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdelayedShowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tisBlockInsertionPointVisible,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"names":["useInBetweenInserter","openRef","InsertionPointOpenRef","isInBetweenInserterDisabled","select","blockEditorStore","getSettings","hasReducedUI","__unstableGetEditorMode","getBlockListSettings","getBlockRootClientId","getBlockIndex","isBlockInsertionPointVisible","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","showInsertionPoint","hideInsertionPoint","delayedShowInsertionPoint","trailing","node","onMouseMove","event","current","target","classList","contains","cancel","rootClientId","blockElement","getAttribute","closest","orientation","offsetTop","clientY","offsetLeft","clientX","children","Array","from","element","find","blockEl","blockElRect","getBoundingClientRect","top","left","id","firstElementChild","clientId","slice","length","includes","elementRect","bottom","right","index","__unstableWithInserter","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIO,SAASA,oBAAT,GAAgC;AACtC,QAAMC,OAAO,GAAG,yBAAYC,qCAAZ,CAAhB;AACA,QAAMC,2BAA2B,GAAG,qBACjCC,MAAF,IACCA,MAAM,CAAEC,YAAF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ect, useDebounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().hasReducedUI ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tisBlockInsertionPointVisible,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t} = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst delayedShowInsertionPoint = useDebounce( showInsertionPoint, 500, {\n\t\ttrailing: true,\n\t} );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\tif ( openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\t// Don't set the insertion point if the template is locked.\n\t\t\t\tif ( getTemplateLock( rootClientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst orientation =\n\t\t\t\t\tgetBlockListSettings( rootClientId )?.orientation ||\n\t\t\t\t\t'vertical';\n\t\t\t\tconst offsetTop = event.clientY;\n\t\t\t\tconst offsetLeft = event.clientX;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\tconst blockElRect = blockEl.getBoundingClientRect();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockElRect.top > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\tblockElRect.left > offsetLeft )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter when hovering above (conflicts with\n\t\t\t\t// block toolbar) or inside selected block(s).\n\t\t\t\tif ( getSelectedBlockClientIds().includes( clientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdelayedShowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tisBlockInsertionPointVisible,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"]}
|
|
@@ -106,10 +106,10 @@ function BlockParentSelector() {
|
|
|
106
106
|
onClick: () => selectBlock(firstParentClientId),
|
|
107
107
|
label: (0, _i18n.sprintf)(
|
|
108
108
|
/* translators: %s: Name of the block's parent. */
|
|
109
|
-
(0, _i18n.__)('Select %s'), blockInformation.title),
|
|
109
|
+
(0, _i18n.__)('Select %s'), blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.title),
|
|
110
110
|
showTooltip: true,
|
|
111
111
|
icon: (0, _element.createElement)(_blockIcon.default, {
|
|
112
|
-
icon: blockInformation.icon
|
|
112
|
+
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon
|
|
113
113
|
})
|
|
114
114
|
}));
|
|
115
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-parent-selector/index.js"],"names":["BlockParentSelector","selectBlock","toggleBlockHighlight","blockEditorStore","firstParentClientId","shouldHide","hasReducedUI","select","getBlockName","getBlockParents","getSelectedBlockClientId","getSettings","hasBlockSupport","blocksStore","selectedBlockClientId","parents","_firstParentClientId","length","parentBlockName","_parentBlockType","settings","blockInformation","nodeRef","gestures","showMoversGestures","ref","onChange","isFocused","undefined","title","icon"],"mappings":";;;;;;;;;AAOA;;;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAOA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MACL,u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;AAP8D,GAAvB,CAAzC;;AAUA,MAAKtB,UAAU,IAAID,mBAAmB,KAAKwB,SAA3C,EAAuD;AACtD,WAAO,IAAP;AACA;;AAED,SACC;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,GAAG,EAAGxB,mBAFP;AAGC,IAAA,GAAG,EAAGkB;AAHP,KAIME,kBAJN,GAMC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,OAAO,EAAG,MAAMvB,WAAW,CAAEG,mBAAF,CAF5B;AAGC,IAAA,KAAK,EAAG;AACP;AACA,kBAAI,WAAJ,CAFO,EAGPiB,gBAAgB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-parent-selector/index.js"],"names":["BlockParentSelector","selectBlock","toggleBlockHighlight","blockEditorStore","firstParentClientId","shouldHide","hasReducedUI","select","getBlockName","getBlockParents","getSelectedBlockClientId","getSettings","hasBlockSupport","blocksStore","selectedBlockClientId","parents","_firstParentClientId","length","parentBlockName","_parentBlockType","settings","blockInformation","nodeRef","gestures","showMoversGestures","ref","onChange","isFocused","undefined","title","icon"],"mappings":";;;;;;;;;AAOA;;;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAOA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MACL,uBAAaC,YAAb,CADD;AAEA,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,UAAvB;AAAmCC,IAAAA;AAAnC,MAAoD,qBACvDC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,eAFK;AAGLC,MAAAA,wBAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEJ,YAAF,CALV;AAMA,UAAM;AAAES,MAAAA;AAAF,QAAsBL,MAAM,CAAEM,aAAF,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AAW,CAAEG,mBAAF,CAF5B;AAGC,IAAA,KAAK,EAAG;AACP;AACA,kBAAI,WAAJ,CAFO,EAGPiB,gBAHO,aAGPA,gBAHO,uBAGPA,gBAAgB,CAAEQ,KAHX,CAHT;AAQC,IAAA,WAAW,MARZ;AASC,IAAA,IAAI,EAAG,4BAAC,kBAAD;AAAW,MAAA,IAAI,EAAGR,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAES;AAApC;AATR,IAND,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport { useShowMoversGestures } from '../block-toolbar/utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Block parent selector component, displaying the hierarchy of the\n * current block selection as a single icon to \"go up\" a level.\n *\n * @return {WPComponent} Parent block selector.\n */\nexport default function BlockParentSelector() {\n\tconst { selectBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { firstParentClientId, shouldHide, hasReducedUI } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { hasBlockSupport } = select( blocksStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\t\tconst _firstParentClientId = parents[ parents.length - 1 ];\n\t\t\tconst parentBlockName = getBlockName( _firstParentClientId );\n\t\t\tconst _parentBlockType = getBlockType( parentBlockName );\n\t\t\tconst settings = getSettings();\n\t\t\treturn {\n\t\t\t\tfirstParentClientId: _firstParentClientId,\n\t\t\t\tshouldHide: ! hasBlockSupport(\n\t\t\t\t\t_parentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasReducedUI: settings.hasReducedUI,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\n\t// Allows highlighting the parent block outline when focusing or hovering\n\t// the parent block selector within the child.\n\tconst nodeRef = useRef();\n\tconst { gestures: showMoversGestures } = useShowMoversGestures( {\n\t\tref: nodeRef,\n\t\tonChange( isFocused ) {\n\t\t\tif ( isFocused && hasReducedUI ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttoggleBlockHighlight( firstParentClientId, isFocused );\n\t\t},\n\t} );\n\n\tif ( shouldHide || firstParentClientId === undefined ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-parent-selector\"\n\t\t\tkey={ firstParentClientId }\n\t\t\tref={ nodeRef }\n\t\t\t{ ...showMoversGestures }\n\t\t>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"block-editor-block-parent-selector__button\"\n\t\t\t\tonClick={ () => selectBlock( firstParentClientId ) }\n\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t/* translators: %s: Name of the block's parent. */\n\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\tblockInformation?.title\n\t\t\t\t) }\n\t\t\t\tshowTooltip\n\t\t\t\ticon={ <BlockIcon icon={ blockInformation?.icon } /> }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -195,7 +195,9 @@ function BlockPopoverInbetween(_ref) {
|
|
|
195
195
|
|
|
196
196
|
previousElement.ownerDocument.defaultView.addEventListener('resize', forcePopoverRecompute);
|
|
197
197
|
return () => {
|
|
198
|
-
|
|
198
|
+
var _previousElement$owne;
|
|
199
|
+
|
|
200
|
+
(_previousElement$owne = previousElement.ownerDocument.defaultView) === null || _previousElement$owne === void 0 ? void 0 : _previousElement$owne.removeEventListener('resize', forcePopoverRecompute);
|
|
199
201
|
};
|
|
200
202
|
}, [previousElement]); // If there's either a previous or a next element, show the inbetween popover.
|
|
201
203
|
// Note that drag and drop uses the inbetween popover to show the drop indicator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAKA,MAAMA,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;AAEO,MAAMC,qBAAqB,GAAG,6BAA9B;;;AAEP,SAASC,qBAAT,OAOI;AAAA,MAP4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,YAF+B;AAG/BC,IAAAA,QAH+B;AAI/BC,IAAAA,qBAJ+B;AAK/BC,IAAAA,oBAL+B;AAM/B,OAAGC;AAN4B,GAO5B;AACH;AACA,QAAM,CAAEC,uBAAF,EAA2BC,qBAA3B,IAAqD,0BAC1D;AACEC,EAAAA,CAAF,IAAS,CAAEA,CAAC,GAAG,CAAN,IAAYb,6BAFqC,EAG1D,CAH0D,CAA3D;AAMA,QAAM;AAAEc,IA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BX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGnB,QAJH,CArBD,CADD;AA8BA;AACA;;eAEcH,qB","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\tconst style = 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 {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\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\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\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\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.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\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 = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\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}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\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=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],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AAEC,WAAzB,IAA0C,CAAER,SAAjD,EAA6D;AAC5D,WAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGyB,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,MAAM,EAAGL,aAHV;AAIC,IAAA,YAAY,EAAG,KAJhB,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAG5B,qBAAqB,IAAI,IAP/C,CAQC;AACA;AATD;AAUC,IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBS;AAV7B,KAWML,KAXN;AAYC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEX,uCAFW,EAGXA,KAAK,CAACwC,SAHK,CAZb;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC;AAnBX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGnB,QAJH,CArBD,CADD;AA8BA;AACA;;eAEcH,qB","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\tconst style = 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 {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\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\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\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\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.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\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 = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\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}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\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=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\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"]}
|
|
@@ -48,18 +48,7 @@ function BlockPopover(_ref, ref) {
|
|
|
48
48
|
const selectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
|
|
49
49
|
const lastSelectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
|
|
50
50
|
const mergedRefs = (0, _compose.useMergeRefs)([ref, (0, _usePopoverScroll.default)(__unstableContentRef)]);
|
|
51
|
-
const
|
|
52
|
-
if (!selectedElement || lastSelectedElement !== selectedElement) {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
position: 'absolute',
|
|
58
|
-
width: selectedElement.offsetWidth,
|
|
59
|
-
height: selectedElement.offsetHeight
|
|
60
|
-
};
|
|
61
|
-
}, [selectedElement, lastSelectedElement, __unstableRefreshSize]);
|
|
62
|
-
const [popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor] = (0, _element.useReducer)( // Module is there to make sure that the counter doesn't overflow.
|
|
51
|
+
const [popoverDimensionsRecomputeCounter, forceRecomputePopoverDimensions] = (0, _element.useReducer)( // Module is there to make sure that the counter doesn't overflow.
|
|
63
52
|
s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0); // When blocks are moved up/down, they are animated to their new position by
|
|
64
53
|
// updating the `transform` property manually (i.e. without using CSS
|
|
65
54
|
// transitions or animations). The animation, which can also scroll the block
|
|
@@ -73,7 +62,7 @@ function BlockPopover(_ref, ref) {
|
|
|
73
62
|
return;
|
|
74
63
|
}
|
|
75
64
|
|
|
76
|
-
const observer = new window.MutationObserver(
|
|
65
|
+
const observer = new window.MutationObserver(forceRecomputePopoverDimensions);
|
|
77
66
|
observer.observe(selectedElement, {
|
|
78
67
|
attributes: true
|
|
79
68
|
});
|
|
@@ -81,11 +70,25 @@ function BlockPopover(_ref, ref) {
|
|
|
81
70
|
observer.disconnect();
|
|
82
71
|
};
|
|
83
72
|
}, [selectedElement]);
|
|
73
|
+
const style = (0, _element.useMemo)(() => {
|
|
74
|
+
if ( // popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
75
|
+
// than 0. This check is only there to satisfy the correctness of the
|
|
76
|
+
// exhaustive-deps rule for the `useMemo` hook.
|
|
77
|
+
popoverDimensionsRecomputeCounter < 0 || !selectedElement || lastSelectedElement !== selectedElement) {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
width: selectedElement.offsetWidth,
|
|
84
|
+
height: selectedElement.offsetHeight
|
|
85
|
+
};
|
|
86
|
+
}, [selectedElement, lastSelectedElement, __unstableRefreshSize, popoverDimensionsRecomputeCounter]);
|
|
84
87
|
const popoverAnchor = (0, _element.useMemo)(() => {
|
|
85
|
-
if ( //
|
|
88
|
+
if ( // popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
86
89
|
// than 0. This check is only there to satisfy the correctness of the
|
|
87
90
|
// exhaustive-deps rule for the `useMemo` hook.
|
|
88
|
-
|
|
91
|
+
popoverDimensionsRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement) {
|
|
89
92
|
return undefined;
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -110,7 +113,7 @@ function BlockPopover(_ref, ref) {
|
|
|
110
113
|
|
|
111
114
|
ownerDocument: selectedElement.ownerDocument
|
|
112
115
|
};
|
|
113
|
-
}, [bottomClientId, lastSelectedElement, selectedElement,
|
|
116
|
+
}, [bottomClientId, lastSelectedElement, selectedElement, popoverDimensionsRecomputeCounter]);
|
|
114
117
|
|
|
115
118
|
if (!selectedElement || bottomClientId && !lastSelectedElement) {
|
|
116
119
|
return null;
|
|
@@ -119,12 +122,12 @@ function BlockPopover(_ref, ref) {
|
|
|
119
122
|
return (0, _element.createElement)(_components.Popover, (0, _extends2.default)({
|
|
120
123
|
ref: mergedRefs,
|
|
121
124
|
animate: false,
|
|
122
|
-
position: "top right left",
|
|
123
125
|
focusOnMount: false,
|
|
124
126
|
anchor: popoverAnchor // Render in the old slot if needed for backward compatibility,
|
|
125
127
|
// otherwise render in place (not in the default popover slot).
|
|
126
128
|
,
|
|
127
129
|
__unstableSlotName: __unstablePopoverSlot || null,
|
|
130
|
+
placement: "top-start",
|
|
128
131
|
resize: false,
|
|
129
132
|
flip: false,
|
|
130
133
|
shift: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","s","observer","window","MutationObserver","observe","attributes","disconnect","style","position","width","offsetWidth","height","offsetHeight","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","className"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAWA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAIA,MAAMA,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;;AAEA,SAASC,YAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;A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K;;AA+BNgB,MAAAA,aAAa,EAAEhC,eAAe,CAACgC;AA/BzB,KAAP;AAiCA,GA7CqB,EA6CnB,CACFvC,cADE,EAEFQ,mBAFE,EAGFD,eAHE,EAIFG,iCAJE,CA7CmB,CAAtB;;AAoDA,MAAK,CAAEH,eAAF,IAAuBP,cAAc,IAAI,CAAEQ,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGC,UADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,MAAM,EAAGgB,aAJV,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAGrB,qBAAqB,IAAI,IAP/C;AAQC,IAAA,SAAS,EAAC,WARX;AASC,IAAA,MAAM,EAAG,KATV;AAUC,IAAA,IAAI,EAAG,KAVR;AAWC,IAAA,KAAK;AAXN,KAYME,KAZN;AAaC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEXA,KAAK,CAACkC,SAFK;AAbb,MAkBGrC,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGgB;AAAb,KAAuBlB,QAAvB,CAlB5B,EAmBG,CAAEE,qBAAF,IAA2BF,QAnB9B,CADD;AAuBA;;eAEc,yBAAYJ,YAAZ,C","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\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\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>\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"]}
|
|
@@ -222,16 +222,16 @@ function BlockSettingsDropdown(_ref2) {
|
|
|
222
222
|
blocks: blocks,
|
|
223
223
|
onCopy: onCopy
|
|
224
224
|
}), canDuplicate && (0, _element.createElement)(_components.MenuItem, {
|
|
225
|
-
onClick: (0,
|
|
225
|
+
onClick: (0, _compose.pipe)(onClose, onDuplicate, updateSelectionAfterDuplicate),
|
|
226
226
|
shortcut: shortcuts.duplicate
|
|
227
227
|
}, (0, _i18n.__)('Duplicate')), canInsertDefaultBlock && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
|
|
228
|
-
onClick: (0,
|
|
228
|
+
onClick: (0, _compose.pipe)(onClose, onInsertBefore),
|
|
229
229
|
shortcut: shortcuts.insertBefore
|
|
230
230
|
}, (0, _i18n.__)('Insert before')), (0, _element.createElement)(_components.MenuItem, {
|
|
231
|
-
onClick: (0,
|
|
231
|
+
onClick: (0, _compose.pipe)(onClose, onInsertAfter),
|
|
232
232
|
shortcut: shortcuts.insertAfter
|
|
233
233
|
}, (0, _i18n.__)('Insert after'))), canMove && !onlyBlock && (0, _element.createElement)(_components.MenuItem, {
|
|
234
|
-
onClick: (0,
|
|
234
|
+
onClick: (0, _compose.pipe)(onClose, onMoveTo)
|
|
235
235
|
}, (0, _i18n.__)('Move to')), count === 1 && (0, _element.createElement)(_blockModeToggle.default, {
|
|
236
236
|
clientId: firstBlockClientId,
|
|
237
237
|
onToggle: onClose
|
|
@@ -246,7 +246,7 @@ function BlockSettingsDropdown(_ref2) {
|
|
|
246
246
|
}) : _element.Children.map(child => (0, _element.cloneElement)(child, {
|
|
247
247
|
onClose
|
|
248
248
|
})), canRemove && (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
|
|
249
|
-
onClick: (0,
|
|
249
|
+
onClick: (0, _compose.pipe)(onClose, onRemove, updateSelectionAfterRemove),
|
|
250
250
|
shortcut: shortcuts.remove
|
|
251
251
|
}, removeBlockLabel)));
|
|
252
252
|
});
|