@wordpress/block-editor 10.4.0 → 10.5.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 +7 -0
- package/README.md +0 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -3
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +44 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.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/inner-blocks/index.js +5 -3
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +39 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +13 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +39 -26
- package/build-style/style.css +39 -26
- package/package.json +28 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-list/style.scss +10 -5
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +7 -4
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +76 -16
- package/src/hooks/layout.js +2 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +16 -9
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block-contents.js"],"names":["ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","blockEditorStore","isBlockMoveTarget","className","draggableClientIds","includes","draggable","onDragStart","onDragEnd"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,qBAAqB,GAAG,yBAC7B,OAaCC,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,MAAsD,qBACzDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,sBAAF;AAA0BC,MAAAA;AAA1B,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,WAAO;AACNL,MAAAA,mBAAmB,EAAEG,sBAAsB,EADrC;AAENF,MAAAA,0BAA0B,EAAEG,wBAAwB;AAF9C,KAAP;AAIA,GAR0D,EAS3D,CAAEL,QAAF,CAT2D,CAA5D;AAYA,QAAMO,iBAAiB,GACtBN,mBAAmB,IAAIC,0BAA0B,KAAKF,QADvD;AAGA,QAAMQ,SAAS,GAAG,yBAAY,uCAAZ,EAAqD;AACtE,0BAAsBD;AADgD,GAArD,CAAlB,CAlBI,CAsBJ;AACA;AACA;AACA;;AACA,QAAME,kBAAkB,GAAGX,iBAAiB,CAACY,QAAlB,CAA4BV,QAA5B,IACxBF,iBADwB,GAExB,CAAEE,QAAF,CAFH;AAIA,SACC,4BAAC,uBAAD;AAAgB,IAAA,SAAS,EAAGS;AAA5B,KACG;AAAA,QAAE;AAAEE,MAAAA,SAAF;AAAaC,MAAAA,WAAb;AAA0BC,MAAAA;AAA1B,KAAF;AAAA,WACD,4BAAC,0BAAD;AACC,MAAA,GAAG,EAAGxB,GADP;AAEC,MAAA,SAAS,EAAGmB,SAFb;AAGC,MAAA,KAAK,EAAGhB,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,EAAGe,SAVb;AAWC,MAAA,WAAW,EAAGC,WAXf;AAYC,MAAA,SAAS,EAAGC,SAZb;AAaC,MAAA,UAAU,EAAGhB;AAbd,OAcME,KAdN,EADC;AAAA,GADH,CADD;AAsBA,CAnE4B,CAA9B;eAsEeX,qB","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 { hasBlockMovingClientId, getSelectedBlockClientId } =\n\t\t\t\t\tselect( 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"]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
16
|
+
var _icons = require("@wordpress/icons");
|
|
17
|
+
|
|
18
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
19
|
+
|
|
20
|
+
var _blockIcon = _interopRequireDefault(require("../block-icon"));
|
|
21
|
+
|
|
22
|
+
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
23
|
+
|
|
24
|
+
var _useBlockDisplayTitle = _interopRequireDefault(require("../block-title/use-block-display-title"));
|
|
25
|
+
|
|
26
|
+
var _expander = _interopRequireDefault(require("./expander"));
|
|
27
|
+
|
|
28
|
+
var _blockLock = require("../block-lock");
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* External dependencies
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* WordPress dependencies
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Internal dependencies
|
|
40
|
+
*/
|
|
41
|
+
function ListViewBlockSelectButton(_ref, ref) {
|
|
42
|
+
let {
|
|
43
|
+
className,
|
|
44
|
+
block: {
|
|
45
|
+
clientId
|
|
46
|
+
},
|
|
47
|
+
onClick,
|
|
48
|
+
onToggleExpanded,
|
|
49
|
+
tabIndex,
|
|
50
|
+
onFocus,
|
|
51
|
+
onDragStart,
|
|
52
|
+
onDragEnd,
|
|
53
|
+
draggable
|
|
54
|
+
} = _ref;
|
|
55
|
+
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
56
|
+
const blockTitle = (0, _useBlockDisplayTitle.default)({
|
|
57
|
+
clientId,
|
|
58
|
+
context: 'list-view'
|
|
59
|
+
});
|
|
60
|
+
const {
|
|
61
|
+
isLocked
|
|
62
|
+
} = (0, _blockLock.useBlockLock)(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
|
|
63
|
+
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
64
|
+
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
65
|
+
// inside the `useOnBlockDrop` hook.
|
|
66
|
+
|
|
67
|
+
const onDragStartHandler = event => {
|
|
68
|
+
event.dataTransfer.clearData();
|
|
69
|
+
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function onKeyDownHandler(event) {
|
|
73
|
+
if (event.keyCode === _keycodes.ENTER || event.keyCode === _keycodes.SPACE) {
|
|
74
|
+
onClick(event);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
|
|
79
|
+
className: (0, _classnames.default)('block-editor-list-view-block-select-button', className),
|
|
80
|
+
onClick: onClick,
|
|
81
|
+
onKeyDown: onKeyDownHandler,
|
|
82
|
+
ref: ref,
|
|
83
|
+
tabIndex: tabIndex,
|
|
84
|
+
onFocus: onFocus,
|
|
85
|
+
onDragStart: onDragStartHandler,
|
|
86
|
+
onDragEnd: onDragEnd,
|
|
87
|
+
draggable: draggable,
|
|
88
|
+
href: `#block-${clientId}`,
|
|
89
|
+
"aria-hidden": true
|
|
90
|
+
}, (0, _element.createElement)(_expander.default, {
|
|
91
|
+
onClick: onToggleExpanded
|
|
92
|
+
}), (0, _element.createElement)(_blockIcon.default, {
|
|
93
|
+
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
|
|
94
|
+
showColors: true
|
|
95
|
+
}), (0, _element.createElement)(_components.__experimentalHStack, {
|
|
96
|
+
alignment: "center",
|
|
97
|
+
className: "block-editor-list-view-block-select-button__label-wrapper",
|
|
98
|
+
justify: "flex-start",
|
|
99
|
+
spacing: 1
|
|
100
|
+
}, (0, _element.createElement)("span", {
|
|
101
|
+
className: "block-editor-list-view-block-select-button__title"
|
|
102
|
+
}, (0, _element.createElement)(_components.__experimentalTruncate, {
|
|
103
|
+
ellipsizeMode: "auto"
|
|
104
|
+
}, blockTitle)), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && (0, _element.createElement)("span", {
|
|
105
|
+
className: "block-editor-list-view-block-select-button__anchor-wrapper"
|
|
106
|
+
}, (0, _element.createElement)(_components.__experimentalTruncate, {
|
|
107
|
+
className: "block-editor-list-view-block-select-button__anchor",
|
|
108
|
+
ellipsizeMode: "auto"
|
|
109
|
+
}, blockInformation.anchor)), isLocked && (0, _element.createElement)("span", {
|
|
110
|
+
className: "block-editor-list-view-block-select-button__lock"
|
|
111
|
+
}, (0, _element.createElement)(_icons.Icon, {
|
|
112
|
+
icon: _icons.lock
|
|
113
|
+
})))));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var _default = (0, _element.forwardRef)(ListViewBlockSelectButton);
|
|
117
|
+
|
|
118
|
+
exports.default = _default;
|
|
119
|
+
//# sourceMappingURL=block-select-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block-select-button.js"],"names":["ListViewBlockSelectButton","ref","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","blockTitle","context","isLocked","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","ENTER","SPACE","icon","anchor","lock"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAOA,SAASA,yBAAT,OAYCC,GAZD,EAaE;AAAA,MAZD;AACCC,IAAAA,SADD;AAECC,IAAAA,KAAK,EAAE;AAAEC,MAAAA;AAAF,KAFR;AAGCC,IAAAA,OAHD;AAICC,IAAAA,gBAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,OAND;AAOCC,IAAAA,WAPD;AAQCC,IAAAA,SARD;AASCC,IAAAA;AATD,GAYC;AACD,QAAMC,gBAAgB,GAAG,yCAA4BR,QAA5B,CAAzB;AACA,QAAMS,UAAU,GAAG,mCAAsB;AACxCT,IAAAA,QADwC;AAExCU,IAAAA,OAAO,EAAE;AAF+B,GAAtB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAe,6BAAcX,QAAd,CAArB,CANC,CAQD;AACA;AACA;AACA;;AACA,QAAMY,kBAAkB,GAAKC,KAAF,IAAa;AACvCA,IAAAA,KAAK,CAACC,YAAN,CAAmBC,SAAnB;AACAV,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAIQ,KAAJ,CAAX;AACA,GAHD;;AAKA,WAASG,gBAAT,CAA2BH,KAA3B,EAAmC;AAClC,QAAKA,KAAK,CAACI,OAAN,KAAkBC,eAAlB,IAA2BL,KAAK,CAACI,OAAN,KAAkBE,eAAlD,EAA0D;AACzDlB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ApBF,CAlBD,CADD,CADD;AAgDA;;eAEc,yBAAY1B,yBAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lock } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\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\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-hidden={ true }\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<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLocked && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _blocks = require("@wordpress/blocks");
|
|
15
|
+
|
|
16
|
+
var _components = require("@wordpress/components");
|
|
17
|
+
|
|
18
|
+
var _compose = require("@wordpress/compose");
|
|
19
|
+
|
|
20
|
+
var _icons = require("@wordpress/icons");
|
|
21
|
+
|
|
22
|
+
var _data = require("@wordpress/data");
|
|
23
|
+
|
|
24
|
+
var _i18n = require("@wordpress/i18n");
|
|
25
|
+
|
|
26
|
+
var _leaf = _interopRequireDefault(require("./leaf"));
|
|
27
|
+
|
|
28
|
+
var _button = require("../block-mover/button");
|
|
29
|
+
|
|
30
|
+
var _blockContents = _interopRequireDefault(require("./block-contents"));
|
|
31
|
+
|
|
32
|
+
var _blockSettingsDropdown = _interopRequireDefault(require("../block-settings-menu/block-settings-dropdown"));
|
|
33
|
+
|
|
34
|
+
var _context = require("./context");
|
|
35
|
+
|
|
36
|
+
var _utils = require("./utils");
|
|
37
|
+
|
|
38
|
+
var _store = require("../../store");
|
|
39
|
+
|
|
40
|
+
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
41
|
+
|
|
42
|
+
var _blockLock = require("../block-lock");
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* External dependencies
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* WordPress dependencies
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Internal dependencies
|
|
54
|
+
*/
|
|
55
|
+
function ListViewBlock(_ref) {
|
|
56
|
+
let {
|
|
57
|
+
block,
|
|
58
|
+
isDragged,
|
|
59
|
+
isSelected,
|
|
60
|
+
isBranchSelected,
|
|
61
|
+
selectBlock,
|
|
62
|
+
position,
|
|
63
|
+
level,
|
|
64
|
+
rowCount,
|
|
65
|
+
siblingBlockCount,
|
|
66
|
+
showBlockMovers,
|
|
67
|
+
path,
|
|
68
|
+
isExpanded,
|
|
69
|
+
selectedClientIds,
|
|
70
|
+
preventAnnouncement,
|
|
71
|
+
selectBlockInCanvas
|
|
72
|
+
} = _ref;
|
|
73
|
+
const cellRef = (0, _element.useRef)(null);
|
|
74
|
+
const [isHovered, setIsHovered] = (0, _element.useState)(false);
|
|
75
|
+
const {
|
|
76
|
+
clientId
|
|
77
|
+
} = block;
|
|
78
|
+
const {
|
|
79
|
+
isLocked,
|
|
80
|
+
isContentLocked
|
|
81
|
+
} = (0, _blockLock.useBlockLock)(clientId);
|
|
82
|
+
const forceSelectionContentLock = (0, _data.useSelect)(select => {
|
|
83
|
+
if (isSelected) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!isContentLocked) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return select(_store.store).hasSelectedInnerBlock(clientId, true);
|
|
92
|
+
}, [isContentLocked, clientId, isSelected]);
|
|
93
|
+
const isFirstSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[0] === clientId;
|
|
94
|
+
const isLastSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
|
|
95
|
+
const {
|
|
96
|
+
toggleBlockHighlight
|
|
97
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
98
|
+
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
99
|
+
const blockName = (0, _data.useSelect)(select => select(_store.store).getBlockName(clientId), [clientId]); // When a block hides its toolbar it also hides the block settings menu,
|
|
100
|
+
// since that menu is part of the toolbar in the editor canvas.
|
|
101
|
+
// List View respects this by also hiding the block settings menu.
|
|
102
|
+
|
|
103
|
+
const showBlockActions = (0, _blocks.hasBlockSupport)(blockName, '__experimentalToolbar', true);
|
|
104
|
+
const instanceId = (0, _compose.useInstanceId)(ListViewBlock);
|
|
105
|
+
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
106
|
+
const blockPositionDescription = (0, _utils.getBlockPositionDescription)(position, siblingBlockCount, level);
|
|
107
|
+
let blockAriaLabel = (0, _i18n.__)('Link');
|
|
108
|
+
|
|
109
|
+
if (blockInformation) {
|
|
110
|
+
blockAriaLabel = isLocked ? (0, _i18n.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
111
|
+
(0, _i18n.__)('%s link (locked)'), blockInformation.title) : (0, _i18n.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the block.
|
|
112
|
+
(0, _i18n.__)('%s link'), blockInformation.title);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const settingsAriaLabel = blockInformation ? (0, _i18n.sprintf)( // translators: %s: The title of the block.
|
|
116
|
+
(0, _i18n.__)('Options for %s block'), blockInformation.title) : (0, _i18n.__)('Options');
|
|
117
|
+
const {
|
|
118
|
+
isTreeGridMounted,
|
|
119
|
+
expand,
|
|
120
|
+
collapse
|
|
121
|
+
} = (0, _context.useListViewContext)();
|
|
122
|
+
const hasSiblings = siblingBlockCount > 0;
|
|
123
|
+
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
124
|
+
const moverCellClassName = (0, _classnames.default)('block-editor-list-view-block__mover-cell', {
|
|
125
|
+
'is-visible': isHovered || isSelected
|
|
126
|
+
});
|
|
127
|
+
const listViewBlockSettingsClassName = (0, _classnames.default)('block-editor-list-view-block__menu-cell', {
|
|
128
|
+
'is-visible': isHovered || isFirstSelectedBlock
|
|
129
|
+
}); // If ListView has experimental features related to the Persistent List View,
|
|
130
|
+
// only focus the selected list item on mount; otherwise the list would always
|
|
131
|
+
// try to steal the focus from the editor canvas.
|
|
132
|
+
|
|
133
|
+
(0, _element.useEffect)(() => {
|
|
134
|
+
if (!isTreeGridMounted && isSelected) {
|
|
135
|
+
cellRef.current.focus();
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
const onMouseEnter = (0, _element.useCallback)(() => {
|
|
139
|
+
setIsHovered(true);
|
|
140
|
+
toggleBlockHighlight(clientId, true);
|
|
141
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
142
|
+
const onMouseLeave = (0, _element.useCallback)(() => {
|
|
143
|
+
setIsHovered(false);
|
|
144
|
+
toggleBlockHighlight(clientId, false);
|
|
145
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
146
|
+
const selectEditorBlock = (0, _element.useCallback)(event => {
|
|
147
|
+
selectBlock(event, clientId);
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
}, [clientId, selectBlock]);
|
|
150
|
+
const updateSelection = (0, _element.useCallback)(newClientId => {
|
|
151
|
+
selectBlock(undefined, newClientId);
|
|
152
|
+
}, [selectBlock]);
|
|
153
|
+
const toggleExpanded = (0, _element.useCallback)(event => {
|
|
154
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
event.stopPropagation();
|
|
157
|
+
|
|
158
|
+
if (isExpanded === true) {
|
|
159
|
+
collapse(clientId);
|
|
160
|
+
} else if (isExpanded === false) {
|
|
161
|
+
expand(clientId);
|
|
162
|
+
}
|
|
163
|
+
}, [clientId, expand, collapse, isExpanded]);
|
|
164
|
+
let colSpan;
|
|
165
|
+
|
|
166
|
+
if (hasRenderedMovers) {
|
|
167
|
+
colSpan = 2;
|
|
168
|
+
} else if (!showBlockActions) {
|
|
169
|
+
colSpan = 3;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const classes = (0, _classnames.default)({
|
|
173
|
+
'is-selected': isSelected || forceSelectionContentLock,
|
|
174
|
+
'is-first-selected': isFirstSelectedBlock,
|
|
175
|
+
'is-last-selected': isLastSelectedBlock,
|
|
176
|
+
'is-branch-selected': isBranchSelected,
|
|
177
|
+
'is-dragging': isDragged,
|
|
178
|
+
'has-single-cell': !showBlockActions
|
|
179
|
+
}); // Only include all selected blocks if the currently clicked on block
|
|
180
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
181
|
+
// to alter a block that isn't part of the selection, they're still able
|
|
182
|
+
// to do so.
|
|
183
|
+
|
|
184
|
+
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
185
|
+
return (0, _element.createElement)(_leaf.default, {
|
|
186
|
+
className: classes,
|
|
187
|
+
onMouseEnter: onMouseEnter,
|
|
188
|
+
onMouseLeave: onMouseLeave,
|
|
189
|
+
onFocus: onMouseEnter,
|
|
190
|
+
onBlur: onMouseLeave,
|
|
191
|
+
level: level,
|
|
192
|
+
position: position,
|
|
193
|
+
rowCount: rowCount,
|
|
194
|
+
path: path,
|
|
195
|
+
id: `list-view-block-${clientId}`,
|
|
196
|
+
"data-block": clientId,
|
|
197
|
+
isExpanded: isContentLocked ? undefined : isExpanded,
|
|
198
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
199
|
+
}, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
200
|
+
className: "block-editor-list-view-block__contents-cell",
|
|
201
|
+
colSpan: colSpan,
|
|
202
|
+
ref: cellRef,
|
|
203
|
+
"aria-label": blockAriaLabel,
|
|
204
|
+
"aria-selected": !!isSelected || forceSelectionContentLock,
|
|
205
|
+
"aria-expanded": isContentLocked ? undefined : isExpanded,
|
|
206
|
+
"aria-describedby": descriptionId
|
|
207
|
+
}, _ref2 => {
|
|
208
|
+
let {
|
|
209
|
+
ref,
|
|
210
|
+
tabIndex,
|
|
211
|
+
onFocus
|
|
212
|
+
} = _ref2;
|
|
213
|
+
return (0, _element.createElement)("div", {
|
|
214
|
+
className: "block-editor-list-view-block__contents-container"
|
|
215
|
+
}, (0, _element.createElement)(_blockContents.default, {
|
|
216
|
+
block: block,
|
|
217
|
+
onClick: selectBlockInCanvas ? selectEditorBlock : event => {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
},
|
|
220
|
+
onToggleExpanded: toggleExpanded,
|
|
221
|
+
isSelected: isSelected,
|
|
222
|
+
position: position,
|
|
223
|
+
siblingBlockCount: siblingBlockCount,
|
|
224
|
+
level: level,
|
|
225
|
+
ref: ref,
|
|
226
|
+
tabIndex: tabIndex,
|
|
227
|
+
onFocus: onFocus,
|
|
228
|
+
isExpanded: isExpanded,
|
|
229
|
+
selectedClientIds: selectedClientIds,
|
|
230
|
+
preventAnnouncement: preventAnnouncement
|
|
231
|
+
}), (0, _element.createElement)("div", {
|
|
232
|
+
className: "block-editor-list-view-block-select-button__description",
|
|
233
|
+
id: descriptionId
|
|
234
|
+
}, blockPositionDescription));
|
|
235
|
+
}), hasRenderedMovers && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
236
|
+
className: moverCellClassName,
|
|
237
|
+
withoutGridItem: true
|
|
238
|
+
}, (0, _element.createElement)(_components.__experimentalTreeGridItem, null, _ref3 => {
|
|
239
|
+
let {
|
|
240
|
+
ref,
|
|
241
|
+
tabIndex,
|
|
242
|
+
onFocus
|
|
243
|
+
} = _ref3;
|
|
244
|
+
return (0, _element.createElement)(_button.BlockMoverUpButton, {
|
|
245
|
+
orientation: "vertical",
|
|
246
|
+
clientIds: [clientId],
|
|
247
|
+
ref: ref,
|
|
248
|
+
tabIndex: tabIndex,
|
|
249
|
+
onFocus: onFocus
|
|
250
|
+
});
|
|
251
|
+
}), (0, _element.createElement)(_components.__experimentalTreeGridItem, null, _ref4 => {
|
|
252
|
+
let {
|
|
253
|
+
ref,
|
|
254
|
+
tabIndex,
|
|
255
|
+
onFocus
|
|
256
|
+
} = _ref4;
|
|
257
|
+
return (0, _element.createElement)(_button.BlockMoverDownButton, {
|
|
258
|
+
orientation: "vertical",
|
|
259
|
+
clientIds: [clientId],
|
|
260
|
+
ref: ref,
|
|
261
|
+
tabIndex: tabIndex,
|
|
262
|
+
onFocus: onFocus
|
|
263
|
+
});
|
|
264
|
+
}))), showBlockActions && (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
265
|
+
className: listViewBlockSettingsClassName,
|
|
266
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
267
|
+
}, _ref5 => {
|
|
268
|
+
let {
|
|
269
|
+
ref,
|
|
270
|
+
tabIndex,
|
|
271
|
+
onFocus
|
|
272
|
+
} = _ref5;
|
|
273
|
+
return (0, _element.createElement)(_blockSettingsDropdown.default, {
|
|
274
|
+
clientIds: dropdownClientIds,
|
|
275
|
+
icon: _icons.moreVertical,
|
|
276
|
+
label: settingsAriaLabel,
|
|
277
|
+
toggleProps: {
|
|
278
|
+
ref,
|
|
279
|
+
className: 'block-editor-list-view-block__menu',
|
|
280
|
+
tabIndex,
|
|
281
|
+
onFocus
|
|
282
|
+
},
|
|
283
|
+
disableOpenOnArrowDown: true,
|
|
284
|
+
__experimentalSelectBlock: updateSelection
|
|
285
|
+
});
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var _default = (0, _element.memo)(ListViewBlock);
|
|
290
|
+
|
|
291
|
+
exports.default = _default;
|
|
292
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block.js"],"names":["ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","selectBlockInCanvas","cellRef","isHovered","setIsHovered","clientId","isLocked","isContentLocked","forceSelectionContentLock","select","blockEditorStore","hasSelectedInnerBlock","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","blockName","getBlockName","showBlockActions","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","title","settingsAriaLabel","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","onMouseEnter","onMouseLeave","selectEditorBlock","event","preventDefault","updateSelection","newClientId","undefined","toggleExpanded","stopPropagation","colSpan","classes","dropdownClientIds","includes","ref","tabIndex","onFocus","moreVertical","className"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AAIA;;AACA;;AAQA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvCA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAcA,SAASA,aAAT,OAgBI;AAAA,MAhBoB;AACvBC,IAAAA,KADuB;AAEvBC,IAAAA,SAFuB;AAGvBC,IAAAA,UAHuB;AAIvBC,IAAAA,gBAJuB;AAKvBC,IAAAA,WALuB;AAMvBC,IAAAA,QANuB;AAOvBC,IAAAA,KAPuB;AAQvBC,IAAAA,QARuB;AASvBC,IAAAA,iBATuB;AAUvBC,IAAAA,eAVuB;AAWvBC,IAAAA,IAXuB;AAYvBC,IAAAA,UAZuB;AAavBC,IAAAA,iBAbuB;AAcvBC,IAAAA,mBAduB;AAevBC,IAAAA;AAfuB,GAgBpB;AACH,QAAMC,OAAO,GAAG,qBAAQ,IAAR,CAAhB;AACA,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAU,KAAV,CAApC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAelB,KAArB;AAEA,QAAM;AAAEmB,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAgC,6BAAcF,QAAd,CAAtC;AACA,QAAMG,yBAAyB,GAAG,qBAC/BC,MAAF,IAAc;AACb,QAAKpB,UAAL,EAAkB;AACjB,aAAO,KAAP;AACA;;AACD,QAAK,CAAEkB,eAAP,EAAyB;AACxB,aAAO,KAAP;AACA;;AACD,WAAOE,MAAM,CAAEC,YAAF,CAAN,CAA2BC,qBAA3B,CACNN,QADM,EAEN,IAFM,CAAP;AAIA,GAZgC,EAajC,CAAEE,eAAF,EAAmBF,QAAnB,EAA6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AAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGX;AAX7B,MADC;AAAA,GAJH,CAzFF,CADD;AAiHA;;eAEc,mBAAMtD,aAAN,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } 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 { getBlockPositionDescription } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\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\tpreventAnnouncement,\n\tselectBlockInCanvas,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { isLocked, isContentLocked } = useBlockLock( clientId );\n\tconst forceSelectionContentLock = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isSelected ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif ( ! isContentLocked ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn select( blockEditorStore ).hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\t\t},\n\t\t[ isContentLocked, clientId, isSelected ]\n\t);\n\n\tconst isFirstSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected && selectedClientIds[ 0 ] === clientId );\n\tconst isLastSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected &&\n\t\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId );\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockName = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockName( clientId ),\n\t\t[ clientId ]\n\t);\n\n\t// When a block hides its toolbar it also hides the block settings menu,\n\t// since that menu is part of the toolbar in the editor canvas.\n\t// List View respects this by also hiding the block settings menu.\n\tconst showBlockActions = hasBlockSupport(\n\t\tblockName,\n\t\t'__experimentalToolbar',\n\t\ttrue\n\t);\n\tconst instanceId = useInstanceId( ListViewBlock );\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\tlet blockAriaLabel = __( 'Link' );\n\tif ( blockInformation ) {\n\t\tblockAriaLabel = isLocked\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the locked block.\n\t\t\t\t\t__( '%s link (locked)' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the block.\n\t\t\t\t\t__( '%s link' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t );\n\t}\n\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\tconst { isTreeGridMounted, expand, collapse } = 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 || isFirstSelectedBlock }\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 ( ! isTreeGridMounted && isSelected ) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\ttoggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\ttoggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateSelection = 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\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected || forceSelectionContentLock,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t} );\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={ isContentLocked ? undefined : isExpanded }\n\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\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\taria-label={ blockAriaLabel }\n\t\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t\t\taria-expanded={ isContentLocked ? undefined : isExpanded }\n\t\t\t\taria-describedby={ descriptionId }\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={\n\t\t\t\t\t\t\t\tselectBlockInCanvas\n\t\t\t\t\t\t\t\t\t? selectEditorBlock\n\t\t\t\t\t\t\t\t\t: ( event ) => {\n\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t}\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\tpreventAnnouncement={ preventAnnouncement }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</div>\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\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t\t\t>\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={ updateSelection }\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"]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
var _block = _interopRequireDefault(require("./block"));
|
|
15
|
+
|
|
16
|
+
var _context = require("./context");
|
|
17
|
+
|
|
18
|
+
var _utils = require("./utils");
|
|
19
|
+
|
|
20
|
+
var _store = require("../../store");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Given a block, returns the total number of blocks in that subtree. This is used to help determine
|
|
32
|
+
* the list position of a block.
|
|
33
|
+
*
|
|
34
|
+
* When a block is collapsed, we do not count their children as part of that total. In the current drag
|
|
35
|
+
* implementation dragged blocks and their children are not counted.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} block block tree
|
|
38
|
+
* @param {Object} expandedState state that notes which branches are collapsed
|
|
39
|
+
* @param {Array} draggedClientIds a list of dragged client ids
|
|
40
|
+
* @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
|
|
41
|
+
* @return {number} block count
|
|
42
|
+
*/
|
|
43
|
+
function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
|
|
44
|
+
var _expandedState$block$;
|
|
45
|
+
|
|
46
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
47
|
+
|
|
48
|
+
if (isDragged) {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
|
|
53
|
+
|
|
54
|
+
if (isExpanded) {
|
|
55
|
+
return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
|
|
62
|
+
var _expandedState$block$2;
|
|
63
|
+
|
|
64
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
65
|
+
|
|
66
|
+
if (isDragged) {
|
|
67
|
+
return count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
|
|
71
|
+
|
|
72
|
+
if (isExpanded && block.innerBlocks.length > 0) {
|
|
73
|
+
return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return count + 1;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function ListViewBranch(props) {
|
|
80
|
+
const {
|
|
81
|
+
blocks,
|
|
82
|
+
selectBlock,
|
|
83
|
+
showBlockMovers,
|
|
84
|
+
selectedClientIds,
|
|
85
|
+
level = 1,
|
|
86
|
+
path = '',
|
|
87
|
+
isBranchSelected = false,
|
|
88
|
+
listPosition = 0,
|
|
89
|
+
fixedListWindow,
|
|
90
|
+
isExpanded,
|
|
91
|
+
parentId,
|
|
92
|
+
shouldShowInnerBlocks = true,
|
|
93
|
+
selectBlockInCanvas
|
|
94
|
+
} = props;
|
|
95
|
+
const isContentLocked = (0, _data.useSelect)(select => {
|
|
96
|
+
return !!(parentId && select(_store.store).getTemplateLock(parentId) === 'contentOnly');
|
|
97
|
+
}, [parentId]);
|
|
98
|
+
const {
|
|
99
|
+
expandedState,
|
|
100
|
+
draggedClientIds
|
|
101
|
+
} = (0, _context.useListViewContext)();
|
|
102
|
+
|
|
103
|
+
if (isContentLocked) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const filteredBlocks = blocks.filter(Boolean);
|
|
108
|
+
const blockCount = filteredBlocks.length;
|
|
109
|
+
let nextPosition = listPosition;
|
|
110
|
+
return (0, _element.createElement)(_element.Fragment, null, filteredBlocks.map((block, index) => {
|
|
111
|
+
var _expandedState$client;
|
|
112
|
+
|
|
113
|
+
const {
|
|
114
|
+
clientId,
|
|
115
|
+
innerBlocks
|
|
116
|
+
} = block;
|
|
117
|
+
|
|
118
|
+
if (index > 0) {
|
|
119
|
+
nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const {
|
|
123
|
+
itemInView
|
|
124
|
+
} = fixedListWindow;
|
|
125
|
+
const blockInView = itemInView(nextPosition);
|
|
126
|
+
const position = index + 1;
|
|
127
|
+
const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
|
|
128
|
+
const hasNestedBlocks = !!(innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length);
|
|
129
|
+
const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
|
|
130
|
+
const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
|
|
131
|
+
const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
|
|
132
|
+
// but asynchronous for any other block.
|
|
133
|
+
|
|
134
|
+
const isSelected = (0, _utils.isClientIdSelected)(clientId, selectedClientIds);
|
|
135
|
+
const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
|
|
136
|
+
return (0, _element.createElement)(_data.AsyncModeProvider, {
|
|
137
|
+
key: clientId,
|
|
138
|
+
value: !isSelected
|
|
139
|
+
}, showBlock && (0, _element.createElement)(_block.default, {
|
|
140
|
+
block: block,
|
|
141
|
+
selectBlock: selectBlock,
|
|
142
|
+
isSelected: isSelected,
|
|
143
|
+
isBranchSelected: isSelectedBranch,
|
|
144
|
+
isDragged: isDragged,
|
|
145
|
+
level: level,
|
|
146
|
+
position: position,
|
|
147
|
+
rowCount: blockCount,
|
|
148
|
+
siblingBlockCount: blockCount,
|
|
149
|
+
showBlockMovers: showBlockMovers,
|
|
150
|
+
path: updatedPath,
|
|
151
|
+
isExpanded: shouldExpand,
|
|
152
|
+
listPosition: nextPosition,
|
|
153
|
+
selectedClientIds: selectedClientIds,
|
|
154
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
155
|
+
}), !showBlock && (0, _element.createElement)("tr", null, (0, _element.createElement)("td", {
|
|
156
|
+
className: "block-editor-list-view-placeholder"
|
|
157
|
+
})), hasNestedBlocks && shouldExpand && !isDragged && (0, _element.createElement)(ListViewBranch, {
|
|
158
|
+
parentId: clientId,
|
|
159
|
+
blocks: innerBlocks,
|
|
160
|
+
selectBlock: selectBlock,
|
|
161
|
+
showBlockMovers: showBlockMovers,
|
|
162
|
+
level: level + 1,
|
|
163
|
+
path: updatedPath,
|
|
164
|
+
listPosition: nextPosition + 1,
|
|
165
|
+
fixedListWindow: fixedListWindow,
|
|
166
|
+
isBranchSelected: isSelectedBranch,
|
|
167
|
+
selectedClientIds: selectedClientIds,
|
|
168
|
+
isExpanded: isExpanded,
|
|
169
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
170
|
+
}));
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
ListViewBranch.defaultProps = {
|
|
175
|
+
selectBlock: () => {}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
var _default = (0, _element.memo)(ListViewBranch);
|
|
179
|
+
|
|
180
|
+
exports.default = _default;
|
|
181
|
+
//# sourceMappingURL=branch.js.map
|