@wordpress/block-editor 8.1.1 → 8.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 +10 -0
- package/README.md +0 -24
- package/build/components/block-list/block.js +16 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +1 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +3 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +25 -27
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-settings/container.native.js +1 -5
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +3 -3
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +19 -7
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +28 -11
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/line-height-control/index.js +61 -43
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/block-contents.js +8 -4
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +0 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +19 -8
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +49 -41
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +139 -0
- package/build/components/list-view/use-block-selection.js.map +1 -0
- package/build/components/list-view/use-list-view-expand-selected-item.js +60 -0
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/list-view/utils.js +29 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/rich-text/index.js +7 -12
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +0 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -0
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +22 -24
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +3 -2
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/hooks/custom-class-name.js +40 -0
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/line-height.js +2 -0
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/style.js +27 -11
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flow.js +7 -5
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +51 -44
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +1 -2
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +2 -2
- package/build/store/reducer.js.map +1 -1
- package/build/utils/index.js +0 -14
- package/build/utils/index.js.map +1 -1
- package/build-module/components/block-list/block.js +17 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +2 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +23 -28
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -6
- package/build-module/components/block-settings/container.native.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/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +3 -3
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +19 -7
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +28 -11
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/line-height-control/index.js +59 -43
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +8 -4
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +0 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +19 -8
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +46 -42
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +123 -0
- package/build-module/components/list-view/use-block-selection.js.map +1 -0
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/list-view/utils.js +25 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -12
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +0 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -0
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +21 -21
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +3 -2
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +38 -0
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/line-height.js +2 -0
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/style.js +26 -11
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flow.js +7 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +48 -41
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +2 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-style/style-rtl.css +3 -12
- package/build-style/style.css +3 -12
- package/package.json +12 -11
- package/src/components/block-list/block.js +27 -3
- package/src/components/block-list/block.native.js +2 -1
- package/src/components/block-list/style.scss +3 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +3 -0
- package/src/components/block-list/use-block-props/use-multi-selection.js +22 -30
- package/src/components/block-settings/container.native.js +5 -6
- package/src/components/index.js +1 -0
- package/src/components/index.native.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +12 -16
- package/src/components/inserter/quick-inserter.js +31 -9
- package/src/components/inserter/search-results.js +54 -42
- package/src/components/line-height-control/README.md +13 -2
- package/src/components/line-height-control/index.js +63 -40
- package/src/components/line-height-control/stories/index.js +33 -0
- package/src/components/line-height-control/test/index.js +61 -0
- package/src/components/list-view/README.md +2 -2
- package/src/components/list-view/block-contents.js +10 -3
- package/src/components/list-view/block-select-button.js +0 -1
- package/src/components/list-view/block.js +29 -9
- package/src/components/list-view/branch.js +1 -0
- package/src/components/list-view/index.js +56 -30
- package/src/components/list-view/test/utils.js +50 -0
- package/src/components/list-view/use-block-selection.js +163 -0
- package/src/components/list-view/use-list-view-expand-selected-item.js +58 -0
- package/src/components/list-view/utils.js +31 -0
- package/src/components/rich-text/index.js +7 -14
- package/src/components/rich-text/use-paste-handler.js +0 -1
- package/src/components/writing-flow/index.js +1 -0
- package/src/components/writing-flow/use-multi-selection.js +17 -20
- package/src/components/writing-flow/use-select-all.js +6 -2
- package/src/hooks/custom-class-name.js +45 -0
- package/src/hooks/line-height.js +2 -0
- package/src/hooks/style.js +26 -11
- package/src/hooks/typography.scss +0 -4
- package/src/layouts/flow.js +10 -5
- package/src/store/actions.js +20 -10
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +0 -1
- package/src/store/reducer.js +2 -1
- package/src/store/test/actions.js +1 -1
- package/src/store/test/reducer.js +9 -0
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/build/utils/theme.js +0 -63
- package/build/utils/theme.js.map +0 -1
- package/build-module/utils/theme.js +0 -53
- package/build-module/utils/theme.js.map +0 -1
- package/src/components/line-height-control/style.scss +0 -8
- package/src/components/writing-flow/test/use-multi-selection.js +0 -36
- package/src/utils/theme.js +0 -48
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["__","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["deprecated","__","__experimentalNumberControl","NumberControl","BASE_DEFAULT_VALUE","RESET_VALUE","STEP","isLineHeightDefined","LineHeightControl","value","lineHeight","onChange","__nextHasNoMarginBottom","__unstableInputWidth","isDefined","adjustNextValue","nextValue","wasTypedOrPasted","stateReducer","state","action","includes","payload","event","nativeEvent","inputType","since","version","hint","deprecatedStyles","undefined","marginBottom"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SACCC,kBADD,EAECC,WAFD,EAGCC,IAHD,EAICC,mBAJD,QAKO,SALP;AAOA,eAAe,SAASC,iBAAT,OAMX;AAAA,MANuC;AAC1CC,IAAAA,KAAK,EAAEC,UADmC;AAE1CC,IAAAA,QAF0C;;AAG1C;AACAC,IAAAA,uBAAuB,GAAG,KAJgB;AAK1CC,IAAAA,oBAAoB,GAAG;A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ACC;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,KAAK,EAAGF;AAFT,KAIC,cAAC,aAAD;AACC,IAAA,oBAAoB,EAAGhB,oBADxB;AAEC,IAAA,sBAAsB,EAAGK,YAF1B;AAGC,IAAA,QAAQ,EAAGP,QAHZ;AAIC,IAAA,KAAK,EAAGV,EAAE,CAAE,aAAF,CAJX;AAKC,IAAA,WAAW,EAAGG,kBALf;AAMC,IAAA,IAAI,EAAGE,IANR;AAOC,IAAA,KAAK,EAAGG,KAPT;AAQC,IAAA,GAAG,EAAG;AARP,IAJD,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalNumberControl as NumberControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBASE_DEFAULT_VALUE,\n\tRESET_VALUE,\n\tSTEP,\n\tisLineHeightDefined,\n} from './utils';\n\nexport default function LineHeightControl( {\n\tvalue: lineHeight,\n\tonChange,\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMarginBottom = false,\n\t__unstableInputWidth = '60px',\n} ) {\n\tconst isDefined = isLineHeightDefined( lineHeight );\n\n\tconst adjustNextValue = ( nextValue, wasTypedOrPasted ) => {\n\t\t// Set the next value without modification if lineHeight has been defined\n\t\tif ( isDefined ) return nextValue;\n\n\t\t/**\n\t\t * The following logic handles the initial step up/down action\n\t\t * (from an undefined value state) so that the next values are better suited for\n\t\t * line-height rendering. For example, the first step up should immediately\n\t\t * go to 1.6, rather than the normally expected 0.1.\n\t\t *\n\t\t * Step up/down actions can be triggered by keydowns of the up/down arrow keys,\n\t\t * or by clicking the spin buttons.\n\t\t */\n\t\tswitch ( nextValue ) {\n\t\t\tcase `${ STEP }`:\n\t\t\t\t// Increment by step value\n\t\t\t\treturn BASE_DEFAULT_VALUE + STEP;\n\t\t\tcase '0': {\n\t\t\t\t// This means the user explicitly input '0', rather than stepped down\n\t\t\t\t// from an undefined value state\n\t\t\t\tif ( wasTypedOrPasted ) return nextValue;\n\t\t\t\t// Decrement by step value\n\t\t\t\treturn BASE_DEFAULT_VALUE - STEP;\n\t\t\t}\n\t\t\tcase '':\n\t\t\t\treturn BASE_DEFAULT_VALUE;\n\t\t\tdefault:\n\t\t\t\treturn nextValue;\n\t\t}\n\t};\n\n\tconst stateReducer = ( state, action ) => {\n\t\t// Be careful when changing this — cross-browser behavior of the\n\t\t// `inputType` field in `input` events are inconsistent.\n\t\t// For example, Firefox emits an input event with inputType=\"insertReplacementText\"\n\t\t// on spin button clicks, while other browsers do not even emit an input event.\n\t\tconst wasTypedOrPasted = [ 'insertText', 'insertFromPaste' ].includes(\n\t\t\taction.payload.event.nativeEvent?.inputType\n\t\t);\n\t\tstate.value = adjustNextValue( state.value, wasTypedOrPasted );\n\t\treturn state;\n\t};\n\n\tconst value = isDefined ? lineHeight : RESET_VALUE;\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.blockEditor.LineHeightControl',\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint:\n\t\t\t\t\t'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\tconst deprecatedStyles = __nextHasNoMarginBottom\n\t\t? undefined\n\t\t: { marginBottom: 24 };\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-line-height-control\"\n\t\t\tstyle={ deprecatedStyles }\n\t\t>\n\t\t\t<NumberControl\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\tplaceholder={ BASE_DEFAULT_VALUE }\n\t\t\t\tstep={ STEP }\n\t\t\t\tvalue={ value }\n\t\t\t\tmin={ 0 }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -28,6 +28,7 @@ const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
|
28
28
|
siblingBlockCount,
|
|
29
29
|
level,
|
|
30
30
|
isExpanded,
|
|
31
|
+
selectedClientIds,
|
|
31
32
|
...props
|
|
32
33
|
} = _ref;
|
|
33
34
|
const {
|
|
@@ -38,12 +39,10 @@ const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
|
38
39
|
selectedBlockInBlockEditor
|
|
39
40
|
} = useSelect(select => {
|
|
40
41
|
const {
|
|
41
|
-
getBlockRootClientId,
|
|
42
42
|
hasBlockMovingClientId,
|
|
43
43
|
getSelectedBlockClientId
|
|
44
44
|
} = select(blockEditorStore);
|
|
45
45
|
return {
|
|
46
|
-
rootClientId: getBlockRootClientId(clientId) || '',
|
|
47
46
|
blockMovingClientId: hasBlockMovingClientId(),
|
|
48
47
|
selectedBlockInBlockEditor: getSelectedBlockClientId()
|
|
49
48
|
};
|
|
@@ -51,9 +50,14 @@ const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
|
51
50
|
const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
52
51
|
const className = classnames('block-editor-list-view-block-contents', {
|
|
53
52
|
'is-dropping-before': isBlockMoveTarget
|
|
54
|
-
});
|
|
53
|
+
}); // Only include all selected blocks if the currently clicked on block
|
|
54
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
55
|
+
// to drag a block that isn't part of the selection, they're still able
|
|
56
|
+
// to drag it and rearrange its position.
|
|
57
|
+
|
|
58
|
+
const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
55
59
|
return createElement(BlockDraggable, {
|
|
56
|
-
clientIds:
|
|
60
|
+
clientIds: draggableClientIds
|
|
57
61
|
}, _ref2 => {
|
|
58
62
|
let {
|
|
59
63
|
draggable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","isBlockMoveTarget","className","draggableClientIds","includes","draggable","onDragStart","onDragEnd"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,uBAAtC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,qBAAqB,GAAGL,UAAU,CACvC,OAaCM,GAbD,KAcK;AAAA,MAbJ;AACCC,IAAAA,OADD;AAECC,IAAAA,gBAFD;AAGCC,IAAAA,KAHD;AAICC,IAAAA,UAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,iBAND;AAOCC,IAAAA,KAPD;AAQCC,IAAAA,UARD;AASCC,IAAAA,iBATD;AAUC,OAAGC;AAVJ,GAaI;AACJ,QAAM;AAAEC,IAAAA;AAAF,MAAeR,KAArB;AAEA,QAAM;AAAES,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MAAsDpB,SAAS,CAClEqB,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,sBADK;AAELC,MAAAA;AAFK,QAGFF,MAAM,CAAEhB,gBAAF,CAHV;AAIA,WAAO;AACNc,MAAAA,mBAAmB,EAAEG,sBAAsB,EADrC;AAENF,MAAAA,0BAA0B,EAAEG,wBAAwB;AAF9C,KAAP;AAIA,GAVmE,EAWpE,CAAEL,QAAF,CAXoE,CAArE;AAcA,QAAMM,iBAAiB,GACtBL,mBAAmB,IAAIC,0BAA0B,KAAKF,QADvD;AAGA,QAAMO,SAAS,GAAG1B,UAAU,CAAE,uCAAF,EAA2C;AACtE,0BAAsByB;AADgD,GAA3C,CAA5B,CApBI,CAwBJ;AACA;AACA;AACA;;AACA,QAAME,kBAAkB,GAAGV,iBAAiB,CAACW,QAAlB,CAA4BT,QAA5B,IACxBF,iBADwB,GAExB,CAAEE,QAAF,CAFH;AAIA,SACC,cAAC,cAAD;AAAgB,IAAA,SAAS,EAAGQ;AAA5B,KACG;AAAA,QAAE;AAAEE,MAAAA,SAAF;AAAaC,MAAAA,WAAb;AAA0BC,MAAAA;AAA1B,KAAF;AAAA,WACD,cAAC,yBAAD;AACC,MAAA,GAAG,EAAGvB,GADP;AAEC,MAAA,SAAS,EAAGkB,SAFb;AAGC,MAAA,KAAK,EAAGf,KAHT;AAIC,MAAA,OAAO,EAAGF,OAJX;AAKC,MAAA,gBAAgB,EAAGC,gBALpB;AAMC,MAAA,UAAU,EAAGE,UANd;AAOC,MAAA,QAAQ,EAAGC,QAPZ;AAQC,MAAA,iBAAiB,EAAGC,iBARrB;AASC,MAAA,KAAK,EAAGC,KATT;AAUC,MAAA,SAAS,EAAGc,SAVb;AAWC,MAAA,WAAW,EAAGC,WAXf;AAYC,MAAA,SAAS,EAAGC,SAZb;AAaC,MAAA,UAAU,EAAGf;AAbd,OAcME,KAdN,EADC;AAAA,GADH,CADD;AAsBA,CArEsC,CAAxC;AAwEA,eAAeX,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\tisExpanded,\n\t\t\tselectedClientIds,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\thasBlockMovingClientId,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\t// Only include all selected blocks if the currently clicked on block\n\t\t// is one of the selected blocks. This ensures that if a user attempts\n\t\t// to drag a block that isn't part of the selection, they're still able\n\t\t// to drag it and rearrange its position.\n\t\tconst draggableClientIds = selectedClientIds.includes( clientId )\n\t\t\t? selectedClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn (\n\t\t\t<BlockDraggable clientIds={ draggableClientIds }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<ListViewBlockSelectButton\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockDraggable>\n\t\t);\n\t}\n);\n\nexport default ListViewBlockContents;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","VisuallyHidden","useInstanceId","forwardRef","__","BlockIcon","useBlockDisplayInformation","getBlockPositionDescription","BlockTitle","ListViewExpander","SPACE","ENTER","ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","blockInformation","instanceId","descriptionId","blockPositionDescription","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","VisuallyHidden","useInstanceId","forwardRef","__","BlockIcon","useBlockDisplayInformation","getBlockPositionDescription","BlockTitle","ListViewExpander","SPACE","ENTER","ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","blockInformation","instanceId","descriptionId","blockPositionDescription","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;A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classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { getBlockPositionDescription } from './utils';\nimport BlockTitle from '../block-title';\nimport ListViewExpander from './expander';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tisSelected,\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId( ListViewBlockSelectButton );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<BlockTitle clientId={ clientId } />\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t{ __( '(selected block)' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\tid={ descriptionId }\n\t\t\t>\n\t\t\t\t{ blockPositionDescription }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
|
|
@@ -38,7 +38,8 @@ function ListViewBlock(_ref) {
|
|
|
38
38
|
siblingBlockCount,
|
|
39
39
|
showBlockMovers,
|
|
40
40
|
path,
|
|
41
|
-
isExpanded
|
|
41
|
+
isExpanded,
|
|
42
|
+
selectedClientIds
|
|
42
43
|
} = _ref;
|
|
43
44
|
const cellRef = useRef(null);
|
|
44
45
|
const [isHovered, setIsHovered] = useState(false);
|
|
@@ -82,10 +83,14 @@ function ListViewBlock(_ref) {
|
|
|
82
83
|
highlightBlock(clientId, false);
|
|
83
84
|
}, [clientId, setIsHovered, highlightBlock]);
|
|
84
85
|
const selectEditorBlock = useCallback(event => {
|
|
85
|
-
event
|
|
86
|
-
selectBlock(clientId);
|
|
86
|
+
selectBlock(event, clientId);
|
|
87
87
|
}, [clientId, selectBlock]);
|
|
88
|
+
const selectDuplicatedBlock = useCallback(newClientId => {
|
|
89
|
+
selectBlock(undefined, newClientId);
|
|
90
|
+
}, [selectBlock]);
|
|
88
91
|
const toggleExpanded = useCallback(event => {
|
|
92
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
93
|
+
event.preventDefault();
|
|
89
94
|
event.stopPropagation();
|
|
90
95
|
|
|
91
96
|
if (isExpanded === true) {
|
|
@@ -112,8 +117,13 @@ function ListViewBlock(_ref) {
|
|
|
112
117
|
'has-single-cell': hideBlockActions
|
|
113
118
|
});
|
|
114
119
|
const blockInformation = useBlockDisplayInformation(clientId);
|
|
115
|
-
const settingsAriaLabel = sprintf( // translators: %s: The title of the block.
|
|
116
|
-
__('Options for %s block'), blockInformation.title);
|
|
120
|
+
const settingsAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block.
|
|
121
|
+
__('Options for %s block'), blockInformation.title) : __('Options'); // Only include all selected blocks if the currently clicked on block
|
|
122
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
123
|
+
// to alter a block that isn't part of the selection, they're still able
|
|
124
|
+
// to do so.
|
|
125
|
+
|
|
126
|
+
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
117
127
|
return createElement(ListViewLeaf, {
|
|
118
128
|
className: classes,
|
|
119
129
|
onMouseEnter: onMouseEnter,
|
|
@@ -150,7 +160,8 @@ function ListViewBlock(_ref) {
|
|
|
150
160
|
ref: ref,
|
|
151
161
|
tabIndex: tabIndex,
|
|
152
162
|
onFocus: onFocus,
|
|
153
|
-
isExpanded: isExpanded
|
|
163
|
+
isExpanded: isExpanded,
|
|
164
|
+
selectedClientIds: selectedClientIds
|
|
154
165
|
}));
|
|
155
166
|
}), hasRenderedMovers && createElement(Fragment, null, createElement(TreeGridCell, {
|
|
156
167
|
className: moverCellClassName,
|
|
@@ -190,7 +201,7 @@ function ListViewBlock(_ref) {
|
|
|
190
201
|
onFocus
|
|
191
202
|
} = _ref5;
|
|
192
203
|
return createElement(BlockSettingsDropdown, {
|
|
193
|
-
clientIds:
|
|
204
|
+
clientIds: dropdownClientIds,
|
|
194
205
|
icon: moreVertical,
|
|
195
206
|
label: settingsAriaLabel,
|
|
196
207
|
toggleProps: {
|
|
@@ -200,7 +211,7 @@ function ListViewBlock(_ref) {
|
|
|
200
211
|
onFocus
|
|
201
212
|
},
|
|
202
213
|
disableOpenOnArrowDown: true,
|
|
203
|
-
__experimentalSelectBlock:
|
|
214
|
+
__experimentalSelectBlock: selectDuplicatedBlock
|
|
204
215
|
});
|
|
205
216
|
}));
|
|
206
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["classnames","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","moreVertical","useState","useRef","useEffect","useCallback","memo","useDispatch","sprintf","__","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","store","blockEditorStore","useBlockDisplayInformation","ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","toggleBlockHighlight","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","hideContainerBlockActions","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","selectEditorBlock","event","stopPropagation","toggleExpanded","showBlockActions","hideBlockActions","colSpan","classes","blockInformation","settingsAriaLabel","title","ref","tabIndex","onFocus","className"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,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;AAGC,MAAA,GAAG,EAAG+B,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAJD,EAeC,cAAC,YAAD,QACG;AAAA,QAAE;AAAEF,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,oBAAD;AACC,MAAA,WAAW,EAAC,UADb;AAEC,MAAA,SAAS,EAAG,CAAEjC,QAAF,CAFb;AAGC,MAAA,GAAG,EAAG+B,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAfD,CADD,CAtCF,EAqEGT,gBAAgB,IACjB,cAAC,YAAD;AAAc,IAAA,SAAS,EAAGV;AAA1B,KACG;AAAA,QAAE;AAAEiB,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAG,CAAEjC,QAAF,CADb;AAEC,MAAA,IAAI,EAAGlC,YAFR;AAGC,MAAA,KAAK,EAAG+D,iBAHT;AAIC,MAAA,WAAW,EAAG;AACbE,QAAAA,GADa;AAEbG,QAAAA,SAAS,EAAE,oCAFE;AAGbF,QAAAA,QAHa;AAIbC,QAAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGb;AAX7B,MADC;AAAA,GADH,CAtEF,CADD;AA2FA;;AAED,eAAejD,IAAI,CAAEa,aAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\n\nfunction ListViewBlock( {\n\tblock,\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions: hideContainerBlockActions,\n\t\tisTreeGridMounted,\n\t\texpand,\n\t\tcollapse,\n\t} = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tevent.stopPropagation();\n\t\t\tselectBlock( clientId );\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\tconst showBlockActions =\n\t\twithExperimentalFeatures &&\n\t\t//hide actions for blocks like core/widget-areas\n\t\t( ! hideContainerBlockActions ||\n\t\t\t( hideContainerBlockActions && level > 1 ) );\n\n\tconst hideBlockActions = withExperimentalFeatures && ! showBlockActions;\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( hideBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': hideBlockActions,\n\t} );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst settingsAriaLabel = sprintf(\n\t\t// translators: %s: The title of the block.\n\t\t__( 'Options for %s block' ),\n\t\tblockInformation.title\n\t);\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isExpanded }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && (\n\t\t\t\t<TreeGridCell className={ listViewBlockSettingsClassName }>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ selectEditorBlock }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["classnames","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","moreVertical","useState","useRef","useEffect","useCallback","memo","useDispatch","sprintf","__","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","store","blockEditorStore","useBlockDisplayInformation","ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","cellRef","isHovered","setIsHovered","clientId","toggleBlockHighlight","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","hideContainerBlockActions","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","selectEditorBlock","event","selectDuplicatedBlock","newClientId","undefined","toggleExpanded","preventDefault","stopPropagation","showBlockActions","hideBlockActions","colSpan","classes","blockInformation","settingsAriaLabel","title","dropdownClientIds","includes","ref","tabIndex","onFocus","className"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,uBAHP;AAIA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,IALD,QAMO,oBANP;AAOA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SACCC,kBADD,EAECC,oBAFD,QAGO,uBAHP;AAIA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EC,MAAA,SAAS,EAAG,CAAEvC,QAAF,CAFb;AAGC,MAAA,GAAG,EAAGqC,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAJD,EAeC,cAAC,YAAD,QACG;AAAA,QAAE;AAAEF,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,oBAAD;AACC,MAAA,WAAW,EAAC,UADb;AAEC,MAAA,SAAS,EAAG,CAAEvC,QAAF,CAFb;AAGC,MAAA,GAAG,EAAGqC,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAfD,CADD,CAvCF,EAsEGX,gBAAgB,IACjB,cAAC,YAAD;AAAc,IAAA,SAAS,EAAGd;AAA1B,KACG;AAAA,QAAE;AAAEuB,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAGJ,iBADb;AAEC,MAAA,IAAI,EAAGtE,YAFR;AAGC,MAAA,KAAK,EAAGoE,iBAHT;AAIC,MAAA,WAAW,EAAG;AACbI,QAAAA,GADa;AAEbG,QAAAA,SAAS,EAAE,oCAFE;AAGbF,QAAAA,QAHa;AAIbC,QAAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGjB;AAX7B,MADC;AAAA,GADH,CAvEF,CADD;AA4FA;;AAED,eAAepD,IAAI,CAAEa,aAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\n\nfunction ListViewBlock( {\n\tblock,\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions: hideContainerBlockActions,\n\t\tisTreeGridMounted,\n\t\texpand,\n\t\tcollapse,\n\t} = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst selectDuplicatedBlock = useCallback(\n\t\t( newClientId ) => {\n\t\t\tselectBlock( undefined, newClientId );\n\t\t},\n\t\t[ selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\tconst showBlockActions =\n\t\twithExperimentalFeatures &&\n\t\t//hide actions for blocks like core/widget-areas\n\t\t( ! hideContainerBlockActions ||\n\t\t\t( hideContainerBlockActions && level > 1 ) );\n\n\tconst hideBlockActions = withExperimentalFeatures && ! showBlockActions;\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( hideBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': hideBlockActions,\n\t} );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst settingsAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Options for %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Options' );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isExpanded }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && (\n\t\t\t\t<TreeGridCell className={ listViewBlockSettingsClassName }>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ selectDuplicatedBlock }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
|
|
@@ -130,7 +130,8 @@ function ListViewBranch(props) {
|
|
|
130
130
|
showBlockMovers: showBlockMovers,
|
|
131
131
|
path: updatedPath,
|
|
132
132
|
isExpanded: isExpanded,
|
|
133
|
-
listPosition: nextPosition
|
|
133
|
+
listPosition: nextPosition,
|
|
134
|
+
selectedClientIds: selectedClientIds
|
|
134
135
|
}), !showBlock && createElement("tr", null, createElement("td", {
|
|
135
136
|
className: "block-editor-list-view-placeholder"
|
|
136
137
|
})), hasNestedBlocks && isExpanded && !isDragged && createElement(ListViewBranch, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["compact","memo","AsyncModeProvider","ListViewBlock","useListViewContext","isClientIdSelected","countBlocks","block","expandedState","draggedClientIds","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","showNestedBlocks","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","__experimentalPersistentListViewFeatures","filteredBlocks","blockCount","nextPosition","map","index","usesWindowing","itemInView","blockInView","position","updatedPath","hasNestedBlocks","undefined","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AAEU,SAAF,IACD,0BACC;AAAI,MAAA,SAAS,EAAC;AAAd,MADD,CAnBF,EAuBGF,eAAe,IAAI7B,UAAnB,IAAiC,CAAEH,SAAnC,IACD,cAAC,cAAD;AACC,MAAA,MAAM,EAAGI,WADV;AAEC,MAAA,WAAW,EAAGQ,WAFf;AAGC,MAAA,eAAe,EAAGC,eAHnB;AAIC,MAAA,gBAAgB,EAAGC,gBAJpB;AAKC,MAAA,KAAK,EAAGE,KAAK,GAAG,CALjB;AAMC,MAAA,IAAI,EAAGe,WANR;AAOC,MAAA,YAAY,EAAGP,YAAY,GAAG,CAP/B;AAQC,MAAA,eAAe,EAAGJ,eARnB;AASC,MAAA,gBAAgB,EAAGgB,gBATpB;AAUC,MAAA,iBAAiB,EAAGrB;AAVrB,MAxBF,CADD;AAwCA,GAlFC,CADH,CADD;AAuFA;;AAEDN,cAAc,CAAC4B,YAAf,GAA8B;AAC7BzB,EAAAA,WAAW,EAAE,MAAM,CAAE;AADQ,CAA9B;AAIA,eAAerB,IAAI,CAAEkB,cAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport { compact } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @return {number} block count\n */\nfunction countBlocks( block, expandedState, draggedClientIds ) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? true;\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer( expandedState, draggedClientIds ),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer = ( expandedState, draggedClientIds ) => (\n\tcount,\n\tblock\n) => {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn count;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? true;\n\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\treturn count + countBlocks( block, expandedState, draggedClientIds );\n\t}\n\treturn count + 1;\n};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tshowNestedBlocks,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t} = props;\n\n\tconst {\n\t\texpandedState,\n\t\tdraggedClientIds,\n\t\t__experimentalPersistentListViewFeatures,\n\t} = useListViewContext();\n\n\tconst filteredBlocks = compact( blocks );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst usesWindowing = __experimentalPersistentListViewFeatures;\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\n\t\t\t\tconst blockInView =\n\t\t\t\t\t! usesWindowing || itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks =\n\t\t\t\t\tshowNestedBlocks && !! innerBlocks && !! innerBlocks.length;\n\n\t\t\t\tconst isExpanded = hasNestedBlocks\n\t\t\t\t\t? expandedState[ clientId ] ?? true\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && isExpanded && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tshowNestedBlocks={ showNestedBlocks }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["compact","memo","AsyncModeProvider","ListViewBlock","useListViewContext","isClientIdSelected","countBlocks","block","expandedState","draggedClientIds","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","showNestedBlocks","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","__experimentalPersistentListViewFeatures","filteredBlocks","blockCount","nextPosition","map","index","usesWindowing","itemInView","blockInView","position","updatedPath","hasNestedBlocks","undefined","showBlock","isSelected","isSelectedBranch","defaultProps"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,oBAArB;AACA,SAASC,iB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nC,IACD,cAAC,cAAD;AACC,MAAA,MAAM,EAAGI,WADV;AAEC,MAAA,WAAW,EAAGQ,WAFf;AAGC,MAAA,eAAe,EAAGC,eAHnB;AAIC,MAAA,gBAAgB,EAAGC,gBAJpB;AAKC,MAAA,KAAK,EAAGE,KAAK,GAAG,CALjB;AAMC,MAAA,IAAI,EAAGe,WANR;AAOC,MAAA,YAAY,EAAGP,YAAY,GAAG,CAP/B;AAQC,MAAA,eAAe,EAAGJ,eARnB;AASC,MAAA,gBAAgB,EAAGgB,gBATpB;AAUC,MAAA,iBAAiB,EAAGrB;AAVrB,MAzBF,CADD;AAyCA,GAnFC,CADH,CADD;AAwFA;;AAEDN,cAAc,CAAC4B,YAAf,GAA8B;AAC7BzB,EAAAA,WAAW,EAAE,MAAM,CAAE;AADQ,CAA9B;AAIA,eAAerB,IAAI,CAAEkB,cAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport { compact } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @return {number} block count\n */\nfunction countBlocks( block, expandedState, draggedClientIds ) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? true;\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer( expandedState, draggedClientIds ),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer = ( expandedState, draggedClientIds ) => (\n\tcount,\n\tblock\n) => {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn count;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? true;\n\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\treturn count + countBlocks( block, expandedState, draggedClientIds );\n\t}\n\treturn count + 1;\n};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tshowNestedBlocks,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t} = props;\n\n\tconst {\n\t\texpandedState,\n\t\tdraggedClientIds,\n\t\t__experimentalPersistentListViewFeatures,\n\t} = useListViewContext();\n\n\tconst filteredBlocks = compact( blocks );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst usesWindowing = __experimentalPersistentListViewFeatures;\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\n\t\t\t\tconst blockInView =\n\t\t\t\t\t! usesWindowing || itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks =\n\t\t\t\t\tshowNestedBlocks && !! innerBlocks && !! innerBlocks.length;\n\n\t\t\t\tconst isExpanded = hasNestedBlocks\n\t\t\t\t\t? expandedState[ clientId ] ?? true\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && isExpanded && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tshowNestedBlocks={ showNestedBlocks }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}
|
|
@@ -6,7 +6,7 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
*/
|
|
7
7
|
import { useMergeRefs, __experimentalUseFixedWindowList as useFixedWindowList } from '@wordpress/compose';
|
|
8
8
|
import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
|
|
9
|
-
import { AsyncModeProvider,
|
|
9
|
+
import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
10
10
|
import { useCallback, useEffect, useMemo, useRef, useReducer, forwardRef } from '@wordpress/element';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
/**
|
|
@@ -16,53 +16,43 @@ import { __ } from '@wordpress/i18n';
|
|
|
16
16
|
import ListViewBranch from './branch';
|
|
17
17
|
import { ListViewContext } from './context';
|
|
18
18
|
import ListViewDropIndicator from './drop-indicator';
|
|
19
|
+
import useBlockSelection from './use-block-selection';
|
|
19
20
|
import useListViewClientIds from './use-list-view-client-ids';
|
|
20
21
|
import useListViewDropZone from './use-list-view-drop-zone';
|
|
22
|
+
import useListViewExpandSelectedItem from './use-list-view-expand-selected-item';
|
|
21
23
|
import { store as blockEditorStore } from '../../store';
|
|
22
24
|
|
|
23
|
-
const noop = () => {};
|
|
24
|
-
|
|
25
25
|
const expanded = (state, action) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
case 'collapse':
|
|
35
|
-
return { ...state,
|
|
36
|
-
...{
|
|
37
|
-
[action.clientId]: false
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
default:
|
|
42
|
-
return state;
|
|
26
|
+
if (Array.isArray(action.clientIds)) {
|
|
27
|
+
return { ...state,
|
|
28
|
+
...action.clientIds.reduce((newState, id) => ({ ...newState,
|
|
29
|
+
[id]: action.type === 'expand'
|
|
30
|
+
}), {})
|
|
31
|
+
};
|
|
43
32
|
}
|
|
33
|
+
|
|
34
|
+
return state;
|
|
44
35
|
};
|
|
36
|
+
|
|
37
|
+
export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
45
38
|
/**
|
|
46
39
|
* Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a
|
|
47
40
|
* recursive component (it renders itself), so this ensures TreeGrid is only
|
|
48
41
|
* present at the very top of the navigation grid.
|
|
49
42
|
*
|
|
50
|
-
* @param {Object}
|
|
51
|
-
* @param {Array}
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {boolean}
|
|
54
|
-
* @param {boolean}
|
|
55
|
-
* @param {boolean}
|
|
56
|
-
* @param {boolean}
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {Object} ref Forwarded ref
|
|
43
|
+
* @param {Object} props Components props.
|
|
44
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
45
|
+
* @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
|
|
46
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
47
|
+
* @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
|
|
48
|
+
* @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
|
|
49
|
+
* @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
|
|
50
|
+
* @param {Object} ref Forwarded ref
|
|
59
51
|
*/
|
|
60
52
|
|
|
61
|
-
|
|
62
53
|
function ListView(_ref, ref) {
|
|
63
54
|
let {
|
|
64
55
|
blocks,
|
|
65
|
-
onSelect = noop,
|
|
66
56
|
__experimentalFeatures,
|
|
67
57
|
__experimentalPersistentListViewFeatures,
|
|
68
58
|
__experimentalHideContainerBlockActions,
|
|
@@ -75,9 +65,6 @@ function ListView(_ref, ref) {
|
|
|
75
65
|
draggedClientIds,
|
|
76
66
|
selectedClientIds
|
|
77
67
|
} = useListViewClientIds(blocks);
|
|
78
|
-
const {
|
|
79
|
-
selectBlock
|
|
80
|
-
} = useDispatch(blockEditorStore);
|
|
81
68
|
const {
|
|
82
69
|
visibleBlockCount
|
|
83
70
|
} = useSelect(select => {
|
|
@@ -90,10 +77,9 @@ function ListView(_ref, ref) {
|
|
|
90
77
|
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount
|
|
91
78
|
};
|
|
92
79
|
}, [draggedClientIds]);
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, [selectBlock, onSelect]);
|
|
80
|
+
const {
|
|
81
|
+
updateBlockSelection
|
|
82
|
+
} = useBlockSelection();
|
|
97
83
|
const [expandedState, setExpandedState] = useReducer(expanded, {});
|
|
98
84
|
const {
|
|
99
85
|
ref: dropZoneRef,
|
|
@@ -102,13 +88,23 @@ function ListView(_ref, ref) {
|
|
|
102
88
|
const elementRef = useRef();
|
|
103
89
|
const treeGridRef = useMergeRefs([elementRef, dropZoneRef, ref]);
|
|
104
90
|
const isMounted = useRef(false);
|
|
91
|
+
const {
|
|
92
|
+
setSelectedTreeId
|
|
93
|
+
} = useListViewExpandSelectedItem({
|
|
94
|
+
firstSelectedBlockClientId: selectedClientIds[0],
|
|
95
|
+
setExpandedState
|
|
96
|
+
});
|
|
97
|
+
const selectEditorBlock = useCallback((event, clientId) => {
|
|
98
|
+
updateBlockSelection(event, clientId);
|
|
99
|
+
setSelectedTreeId(clientId);
|
|
100
|
+
}, [setSelectedTreeId, updateBlockSelection]);
|
|
105
101
|
useEffect(() => {
|
|
106
102
|
isMounted.current = true;
|
|
107
103
|
}, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
108
104
|
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
109
105
|
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
110
106
|
|
|
111
|
-
const [fixedListWindow] = useFixedWindowList(elementRef,
|
|
107
|
+
const [fixedListWindow] = useFixedWindowList(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
|
|
112
108
|
useWindowing: __experimentalPersistentListViewFeatures,
|
|
113
109
|
windowOverscan: 40
|
|
114
110
|
});
|
|
@@ -119,7 +115,7 @@ function ListView(_ref, ref) {
|
|
|
119
115
|
|
|
120
116
|
setExpandedState({
|
|
121
117
|
type: 'expand',
|
|
122
|
-
clientId
|
|
118
|
+
clientIds: [clientId]
|
|
123
119
|
});
|
|
124
120
|
}, [setExpandedState]);
|
|
125
121
|
const collapse = useCallback(clientId => {
|
|
@@ -129,7 +125,7 @@ function ListView(_ref, ref) {
|
|
|
129
125
|
|
|
130
126
|
setExpandedState({
|
|
131
127
|
type: 'collapse',
|
|
132
|
-
clientId
|
|
128
|
+
clientIds: [clientId]
|
|
133
129
|
});
|
|
134
130
|
}, [setExpandedState]);
|
|
135
131
|
const expandRow = useCallback(row => {
|
|
@@ -142,6 +138,13 @@ function ListView(_ref, ref) {
|
|
|
142
138
|
|
|
143
139
|
collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
|
|
144
140
|
}, [collapse]);
|
|
141
|
+
const focusRow = useCallback((event, startRow, endRow) => {
|
|
142
|
+
if (event.shiftKey) {
|
|
143
|
+
var _startRow$dataset, _endRow$dataset;
|
|
144
|
+
|
|
145
|
+
updateBlockSelection(event, startRow === null || startRow === void 0 ? void 0 : (_startRow$dataset = startRow.dataset) === null || _startRow$dataset === void 0 ? void 0 : _startRow$dataset.block, endRow === null || endRow === void 0 ? void 0 : (_endRow$dataset = endRow.dataset) === null || _endRow$dataset === void 0 ? void 0 : _endRow$dataset.block);
|
|
146
|
+
}
|
|
147
|
+
}, [updateBlockSelection]);
|
|
145
148
|
const contextValue = useMemo(() => ({
|
|
146
149
|
__experimentalFeatures,
|
|
147
150
|
__experimentalPersistentListViewFeatures,
|
|
@@ -162,7 +165,8 @@ function ListView(_ref, ref) {
|
|
|
162
165
|
"aria-label": __('Block navigation structure'),
|
|
163
166
|
ref: treeGridRef,
|
|
164
167
|
onCollapseRow: collapseRow,
|
|
165
|
-
onExpandRow: expandRow
|
|
168
|
+
onExpandRow: expandRow,
|
|
169
|
+
onFocusRow: focusRow
|
|
166
170
|
}, createElement(ListViewContext.Provider, {
|
|
167
171
|
value: contextValue
|
|
168
172
|
}, createElement(ListViewBranch, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useDispatch","useSelect","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useListViewClientIds","useListViewDropZone","store","blockEditorStore","noop","expanded","state","action","type","clientId","ListView","ref","blocks","onSelect","__experimentalFeatures","__experimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","showNestedBlocks","showBlockMovers","props","clientIdsTree","draggedClientIds","selectedClientIds","selectBlock","visibleBlockCount","select","getGlobalBlockCount","getClientIdsOfDescendants","draggedBlockCount","length","selectEditorBlock","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","contextValue","isTreeGridMounted"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,gCAAgC,IAAIC,kBAFrC,QAGO,oBAHP;AAIA,SAASC,sBAAsB,IAAIC,QAAnC,QAAmD,uBAAnD;AACA,SAASC,iBAAT,EAA4BC,WAA5B,EAAyCC,SAAzC,QAA0D,iBAA1D;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,UALD,EAMCC,UAND,QAOO,oBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,UAA3B;AACA,SAASC,eAAT,QAAgC,WAAhC;AACA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,OAAOC,mBAAP,MAAgC,2BAAhC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,QAAL;AACC,aAAO,EAAE,GAAGF,KAAL;AAAY,WAAG;AAAE,WAAEC,MAAM,CAACE,QAAT,GAAqB;AAAvB;AAAf,OAAP;;AACD,SAAK,UAAL;AACC,aAAO,EAAE,GAAGH,KAAL;AAAY,WAAG;AAAE,WAAEC,MAAM,CAACE,QAAT,GAAqB;AAAvB;AAAf,OAAP;;AACD;AACC,aAAOH,KAAP;AANF;AAQA,CATD;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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eALnB;AAMC,IAAA,iBAAiB,EAAGlB;AANrB,KAOMH,KAPN,EADD,CAPD,CALD,CADD;AA2BA;;AACD,eAAexB,UAAU,CAAEe,QAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\nconst expanded = ( state, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'expand':\n\t\t\treturn { ...state, ...{ [ action.clientId ]: true } };\n\t\tcase 'collapse':\n\t\t\treturn { ...state, ...{ [ action.clientId ]: false } };\n\t\tdefault:\n\t\t\treturn state;\n\t}\n};\n\n/**\n * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a\n * recursive component (it renders itself), so this ensures TreeGrid is only\n * present at the very top of the navigation grid.\n *\n * @param {Object} props Components props.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {Function} props.onSelect Block selection callback.\n * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.\n * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.\n * @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)\n * @param {Object} ref Forwarded ref\n */\nfunction ListView(\n\t{\n\t\tblocks,\n\t\tonSelect = noop,\n\t\t__experimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions,\n\t\tshowNestedBlocks,\n\t\tshowBlockMovers,\n\t\t...props\n\t},\n\tref\n) {\n\tconst {\n\t\tclientIdsTree,\n\t\tdraggedClientIds,\n\t\tselectedClientIds,\n\t} = useListViewClientIds( blocks );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { visibleBlockCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getGlobalBlockCount, getClientIdsOfDescendants } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\tconst selectEditorBlock = useCallback(\n\t\t( clientId ) => {\n\t\t\tselectBlock( clientId );\n\t\t\tonSelect( clientId );\n\t\t},\n\t\t[ selectBlock, onSelect ]\n\t);\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\t36,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: __experimentalPersistentListViewFeatures,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientId } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientId } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowNestedBlocks={ showNestedBlocks }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( ListView );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListView","ref","blocks","__experimentalFeatures","__experimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","showNestedBlocks","showBlockMovers","props","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","select","getGlobalBlockCount","getClientIdsOfDescendants","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","clientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,gCAAgC,IA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KC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,kBAAa5C,EAAE,CAAE,4BAAF,CAFhB;AAGC,IAAA,GAAG,EAAG8C,WAHP;AAIC,IAAA,aAAa,EAAGiB,WAJjB;AAKC,IAAA,WAAW,EAAGJ,SALf;AAMC,IAAA,UAAU,EAAGK;AANd,KAQC,cAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGI;AAAlC,KACC,cAAC,cAAD;AACC,IAAA,MAAM,EAAGtC,aADV;AAEC,IAAA,WAAW,EAAGoB,iBAFf;AAGC,IAAA,gBAAgB,EAAGvB,gBAHpB;AAIC,IAAA,eAAe,EAAGC,eAJnB;AAKC,IAAA,eAAe,EAAG0B,eALnB;AAMC,IAAA,iBAAiB,EAAGtB;AANrB,KAOMH,KAPN,EADD,CARD,CALD,CADD;AA4BA;;AACD,eAAe9B,UAAU,CAAEsB,QAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a\n * recursive component (it renders itself), so this ensures TreeGrid is only\n * present at the very top of the navigation grid.\n *\n * @param {Object} props Components props.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.\n * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.\n * @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)\n * @param {Object} ref Forwarded ref\n */\nfunction ListView(\n\t{\n\t\tblocks,\n\t\t__experimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions,\n\t\tshowNestedBlocks,\n\t\tshowBlockMovers,\n\t\t...props\n\t},\n\tref\n) {\n\tconst {\n\t\tclientIdsTree,\n\t\tdraggedClientIds,\n\t\tselectedClientIds,\n\t} = useListViewClientIds( blocks );\n\n\tconst { visibleBlockCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getGlobalBlockCount, getClientIdsOfDescendants } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, clientId ) => {\n\t\t\tupdateBlockSelection( event, clientId );\n\t\t\tsetSelectedTreeId( clientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: __experimentalPersistentListViewFeatures,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowNestedBlocks={ showNestedBlocks }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( ListView );\n"]}
|