@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,85 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
13
|
+
import { forwardRef } from '@wordpress/element';
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import ListViewBlockSelectButton from './block-select-button';
|
|
19
|
+
import BlockDraggable from '../block-draggable';
|
|
20
|
+
import { store as blockEditorStore } from '../../store';
|
|
21
|
+
const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
22
|
+
let {
|
|
23
|
+
onClick,
|
|
24
|
+
onToggleExpanded,
|
|
25
|
+
block,
|
|
26
|
+
isSelected,
|
|
27
|
+
position,
|
|
28
|
+
siblingBlockCount,
|
|
29
|
+
level,
|
|
30
|
+
isExpanded,
|
|
31
|
+
selectedClientIds,
|
|
32
|
+
...props
|
|
33
|
+
} = _ref;
|
|
34
|
+
const {
|
|
35
|
+
clientId
|
|
36
|
+
} = block;
|
|
37
|
+
const {
|
|
38
|
+
blockMovingClientId,
|
|
39
|
+
selectedBlockInBlockEditor
|
|
40
|
+
} = useSelect(select => {
|
|
41
|
+
const {
|
|
42
|
+
hasBlockMovingClientId,
|
|
43
|
+
getSelectedBlockClientId
|
|
44
|
+
} = select(blockEditorStore);
|
|
45
|
+
return {
|
|
46
|
+
blockMovingClientId: hasBlockMovingClientId(),
|
|
47
|
+
selectedBlockInBlockEditor: getSelectedBlockClientId()
|
|
48
|
+
};
|
|
49
|
+
}, [clientId]);
|
|
50
|
+
const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
51
|
+
const className = classnames('block-editor-list-view-block-contents', {
|
|
52
|
+
'is-dropping-before': isBlockMoveTarget
|
|
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];
|
|
59
|
+
return createElement(BlockDraggable, {
|
|
60
|
+
clientIds: draggableClientIds
|
|
61
|
+
}, _ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
draggable,
|
|
64
|
+
onDragStart,
|
|
65
|
+
onDragEnd
|
|
66
|
+
} = _ref2;
|
|
67
|
+
return createElement(ListViewBlockSelectButton, _extends({
|
|
68
|
+
ref: ref,
|
|
69
|
+
className: className,
|
|
70
|
+
block: block,
|
|
71
|
+
onClick: onClick,
|
|
72
|
+
onToggleExpanded: onToggleExpanded,
|
|
73
|
+
isSelected: isSelected,
|
|
74
|
+
position: position,
|
|
75
|
+
siblingBlockCount: siblingBlockCount,
|
|
76
|
+
level: level,
|
|
77
|
+
draggable: draggable,
|
|
78
|
+
onDragStart: onDragStart,
|
|
79
|
+
onDragEnd: onDragEnd,
|
|
80
|
+
isExpanded: isExpanded
|
|
81
|
+
}, props));
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
export default ListViewBlockContents;
|
|
85
|
+
//# sourceMappingURL=block-contents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/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;AAAEC,MAAAA,sBAAF;AAA0BC,MAAAA;AAA1B,QACLF,MAAM,CAAEhB,gBAAF,CADP;AAEA,WAAO;AACNc,MAAAA,mBAAmB,EAAEG,sBAAsB,EADrC;AAENF,MAAAA,0BAA0B,EAAEG,wBAAwB;AAF9C,KAAP;AAIA,GARmE,EASpE,CAAEL,QAAF,CAToE,CAArE;AAYA,QAAMM,iBAAiB,GACtBL,mBAAmB,IAAIC,0BAA0B,KAAKF,QADvD;AAGA,QAAMO,SAAS,GAAG1B,UAAU,CAAE,uCAAF,EAA2C;AACtE,0BAAsByB;AADgD,GAA3C,CAA5B,CAlBI,CAsBJ;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,CAnEsC,CAAxC;AAsEA,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 { 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,101 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Button, __experimentalHStack as HStack, __experimentalTruncate as Truncate } from '@wordpress/components';
|
|
12
|
+
import { forwardRef } from '@wordpress/element';
|
|
13
|
+
import { Icon, lock } from '@wordpress/icons';
|
|
14
|
+
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BlockIcon from '../block-icon';
|
|
20
|
+
import useBlockDisplayInformation from '../use-block-display-information';
|
|
21
|
+
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
22
|
+
import ListViewExpander from './expander';
|
|
23
|
+
import { useBlockLock } from '../block-lock';
|
|
24
|
+
|
|
25
|
+
function ListViewBlockSelectButton(_ref, ref) {
|
|
26
|
+
let {
|
|
27
|
+
className,
|
|
28
|
+
block: {
|
|
29
|
+
clientId
|
|
30
|
+
},
|
|
31
|
+
onClick,
|
|
32
|
+
onToggleExpanded,
|
|
33
|
+
tabIndex,
|
|
34
|
+
onFocus,
|
|
35
|
+
onDragStart,
|
|
36
|
+
onDragEnd,
|
|
37
|
+
draggable
|
|
38
|
+
} = _ref;
|
|
39
|
+
const blockInformation = useBlockDisplayInformation(clientId);
|
|
40
|
+
const blockTitle = useBlockDisplayTitle({
|
|
41
|
+
clientId,
|
|
42
|
+
context: 'list-view'
|
|
43
|
+
});
|
|
44
|
+
const {
|
|
45
|
+
isLocked
|
|
46
|
+
} = useBlockLock(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
|
|
47
|
+
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
48
|
+
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
49
|
+
// inside the `useOnBlockDrop` hook.
|
|
50
|
+
|
|
51
|
+
const onDragStartHandler = event => {
|
|
52
|
+
event.dataTransfer.clearData();
|
|
53
|
+
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function onKeyDownHandler(event) {
|
|
57
|
+
if (event.keyCode === ENTER || event.keyCode === SPACE) {
|
|
58
|
+
onClick(event);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return createElement(Fragment, null, createElement(Button, {
|
|
63
|
+
className: classnames('block-editor-list-view-block-select-button', className),
|
|
64
|
+
onClick: onClick,
|
|
65
|
+
onKeyDown: onKeyDownHandler,
|
|
66
|
+
ref: ref,
|
|
67
|
+
tabIndex: tabIndex,
|
|
68
|
+
onFocus: onFocus,
|
|
69
|
+
onDragStart: onDragStartHandler,
|
|
70
|
+
onDragEnd: onDragEnd,
|
|
71
|
+
draggable: draggable,
|
|
72
|
+
href: `#block-${clientId}`,
|
|
73
|
+
"aria-hidden": true
|
|
74
|
+
}, createElement(ListViewExpander, {
|
|
75
|
+
onClick: onToggleExpanded
|
|
76
|
+
}), createElement(BlockIcon, {
|
|
77
|
+
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
|
|
78
|
+
showColors: true
|
|
79
|
+
}), createElement(HStack, {
|
|
80
|
+
alignment: "center",
|
|
81
|
+
className: "block-editor-list-view-block-select-button__label-wrapper",
|
|
82
|
+
justify: "flex-start",
|
|
83
|
+
spacing: 1
|
|
84
|
+
}, createElement("span", {
|
|
85
|
+
className: "block-editor-list-view-block-select-button__title"
|
|
86
|
+
}, createElement(Truncate, {
|
|
87
|
+
ellipsizeMode: "auto"
|
|
88
|
+
}, blockTitle)), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && createElement("span", {
|
|
89
|
+
className: "block-editor-list-view-block-select-button__anchor-wrapper"
|
|
90
|
+
}, createElement(Truncate, {
|
|
91
|
+
className: "block-editor-list-view-block-select-button__anchor",
|
|
92
|
+
ellipsizeMode: "auto"
|
|
93
|
+
}, blockInformation.anchor)), isLocked && createElement("span", {
|
|
94
|
+
className: "block-editor-list-view-block-select-button__lock"
|
|
95
|
+
}, createElement(Icon, {
|
|
96
|
+
icon: lock
|
|
97
|
+
})))));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default forwardRef(ListViewBlockSelectButton);
|
|
101
|
+
//# 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":["classnames","Button","__experimentalHStack","HStack","__experimentalTruncate","Truncate","forwardRef","Icon","lock","SPACE","ENTER","BlockIcon","useBlockDisplayInformation","useBlockDisplayTitle","ListViewExpander","useBlockLock","ListViewBlockSelectButton","ref","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","blockTitle","context","isLocked","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,sBAAsB,IAAIC,QAH3B,QAIO,uBAJP;AAKA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,E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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,268 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
12
|
+
import { __experimentalTreeGridCell as TreeGridCell, __experimentalTreeGridItem as TreeGridItem } from '@wordpress/components';
|
|
13
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
14
|
+
import { moreVertical } from '@wordpress/icons';
|
|
15
|
+
import { useState, useRef, useEffect, useCallback, memo } from '@wordpress/element';
|
|
16
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
17
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import ListViewLeaf from './leaf';
|
|
23
|
+
import { BlockMoverUpButton, BlockMoverDownButton } from '../block-mover/button';
|
|
24
|
+
import ListViewBlockContents from './block-contents';
|
|
25
|
+
import BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';
|
|
26
|
+
import { useListViewContext } from './context';
|
|
27
|
+
import { getBlockPositionDescription } from './utils';
|
|
28
|
+
import { store as blockEditorStore } from '../../store';
|
|
29
|
+
import useBlockDisplayInformation from '../use-block-display-information';
|
|
30
|
+
import { useBlockLock } from '../block-lock';
|
|
31
|
+
|
|
32
|
+
function ListViewBlock(_ref) {
|
|
33
|
+
let {
|
|
34
|
+
block,
|
|
35
|
+
isDragged,
|
|
36
|
+
isSelected,
|
|
37
|
+
isBranchSelected,
|
|
38
|
+
selectBlock,
|
|
39
|
+
position,
|
|
40
|
+
level,
|
|
41
|
+
rowCount,
|
|
42
|
+
siblingBlockCount,
|
|
43
|
+
showBlockMovers,
|
|
44
|
+
path,
|
|
45
|
+
isExpanded,
|
|
46
|
+
selectedClientIds,
|
|
47
|
+
preventAnnouncement,
|
|
48
|
+
selectBlockInCanvas
|
|
49
|
+
} = _ref;
|
|
50
|
+
const cellRef = useRef(null);
|
|
51
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
52
|
+
const {
|
|
53
|
+
clientId
|
|
54
|
+
} = block;
|
|
55
|
+
const {
|
|
56
|
+
isLocked,
|
|
57
|
+
isContentLocked
|
|
58
|
+
} = useBlockLock(clientId);
|
|
59
|
+
const forceSelectionContentLock = useSelect(select => {
|
|
60
|
+
if (isSelected) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!isContentLocked) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return select(blockEditorStore).hasSelectedInnerBlock(clientId, true);
|
|
69
|
+
}, [isContentLocked, clientId, isSelected]);
|
|
70
|
+
const isFirstSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[0] === clientId;
|
|
71
|
+
const isLastSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
|
|
72
|
+
const {
|
|
73
|
+
toggleBlockHighlight
|
|
74
|
+
} = useDispatch(blockEditorStore);
|
|
75
|
+
const blockInformation = useBlockDisplayInformation(clientId);
|
|
76
|
+
const blockName = useSelect(select => select(blockEditorStore).getBlockName(clientId), [clientId]); // When a block hides its toolbar it also hides the block settings menu,
|
|
77
|
+
// since that menu is part of the toolbar in the editor canvas.
|
|
78
|
+
// List View respects this by also hiding the block settings menu.
|
|
79
|
+
|
|
80
|
+
const showBlockActions = hasBlockSupport(blockName, '__experimentalToolbar', true);
|
|
81
|
+
const instanceId = useInstanceId(ListViewBlock);
|
|
82
|
+
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
83
|
+
const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
|
|
84
|
+
|
|
85
|
+
let blockAriaLabel = __('Link');
|
|
86
|
+
|
|
87
|
+
if (blockInformation) {
|
|
88
|
+
blockAriaLabel = isLocked ? sprintf( // translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
89
|
+
__('%s link (locked)'), blockInformation.title) : sprintf( // translators: %s: The title of the block. This string indicates a link to select the block.
|
|
90
|
+
__('%s link'), blockInformation.title);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const settingsAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block.
|
|
94
|
+
__('Options for %s block'), blockInformation.title) : __('Options');
|
|
95
|
+
const {
|
|
96
|
+
isTreeGridMounted,
|
|
97
|
+
expand,
|
|
98
|
+
collapse
|
|
99
|
+
} = useListViewContext();
|
|
100
|
+
const hasSiblings = siblingBlockCount > 0;
|
|
101
|
+
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
102
|
+
const moverCellClassName = classnames('block-editor-list-view-block__mover-cell', {
|
|
103
|
+
'is-visible': isHovered || isSelected
|
|
104
|
+
});
|
|
105
|
+
const listViewBlockSettingsClassName = classnames('block-editor-list-view-block__menu-cell', {
|
|
106
|
+
'is-visible': isHovered || isFirstSelectedBlock
|
|
107
|
+
}); // If ListView has experimental features related to the Persistent List View,
|
|
108
|
+
// only focus the selected list item on mount; otherwise the list would always
|
|
109
|
+
// try to steal the focus from the editor canvas.
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!isTreeGridMounted && isSelected) {
|
|
113
|
+
cellRef.current.focus();
|
|
114
|
+
}
|
|
115
|
+
}, []);
|
|
116
|
+
const onMouseEnter = useCallback(() => {
|
|
117
|
+
setIsHovered(true);
|
|
118
|
+
toggleBlockHighlight(clientId, true);
|
|
119
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
120
|
+
const onMouseLeave = useCallback(() => {
|
|
121
|
+
setIsHovered(false);
|
|
122
|
+
toggleBlockHighlight(clientId, false);
|
|
123
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
124
|
+
const selectEditorBlock = useCallback(event => {
|
|
125
|
+
selectBlock(event, clientId);
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
}, [clientId, selectBlock]);
|
|
128
|
+
const updateSelection = useCallback(newClientId => {
|
|
129
|
+
selectBlock(undefined, newClientId);
|
|
130
|
+
}, [selectBlock]);
|
|
131
|
+
const toggleExpanded = useCallback(event => {
|
|
132
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
|
|
136
|
+
if (isExpanded === true) {
|
|
137
|
+
collapse(clientId);
|
|
138
|
+
} else if (isExpanded === false) {
|
|
139
|
+
expand(clientId);
|
|
140
|
+
}
|
|
141
|
+
}, [clientId, expand, collapse, isExpanded]);
|
|
142
|
+
let colSpan;
|
|
143
|
+
|
|
144
|
+
if (hasRenderedMovers) {
|
|
145
|
+
colSpan = 2;
|
|
146
|
+
} else if (!showBlockActions) {
|
|
147
|
+
colSpan = 3;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const classes = classnames({
|
|
151
|
+
'is-selected': isSelected || forceSelectionContentLock,
|
|
152
|
+
'is-first-selected': isFirstSelectedBlock,
|
|
153
|
+
'is-last-selected': isLastSelectedBlock,
|
|
154
|
+
'is-branch-selected': isBranchSelected,
|
|
155
|
+
'is-dragging': isDragged,
|
|
156
|
+
'has-single-cell': !showBlockActions
|
|
157
|
+
}); // Only include all selected blocks if the currently clicked on block
|
|
158
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
159
|
+
// to alter a block that isn't part of the selection, they're still able
|
|
160
|
+
// to do so.
|
|
161
|
+
|
|
162
|
+
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
163
|
+
return createElement(ListViewLeaf, {
|
|
164
|
+
className: classes,
|
|
165
|
+
onMouseEnter: onMouseEnter,
|
|
166
|
+
onMouseLeave: onMouseLeave,
|
|
167
|
+
onFocus: onMouseEnter,
|
|
168
|
+
onBlur: onMouseLeave,
|
|
169
|
+
level: level,
|
|
170
|
+
position: position,
|
|
171
|
+
rowCount: rowCount,
|
|
172
|
+
path: path,
|
|
173
|
+
id: `list-view-block-${clientId}`,
|
|
174
|
+
"data-block": clientId,
|
|
175
|
+
isExpanded: isContentLocked ? undefined : isExpanded,
|
|
176
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
177
|
+
}, createElement(TreeGridCell, {
|
|
178
|
+
className: "block-editor-list-view-block__contents-cell",
|
|
179
|
+
colSpan: colSpan,
|
|
180
|
+
ref: cellRef,
|
|
181
|
+
"aria-label": blockAriaLabel,
|
|
182
|
+
"aria-selected": !!isSelected || forceSelectionContentLock,
|
|
183
|
+
"aria-expanded": isContentLocked ? undefined : isExpanded,
|
|
184
|
+
"aria-describedby": descriptionId
|
|
185
|
+
}, _ref2 => {
|
|
186
|
+
let {
|
|
187
|
+
ref,
|
|
188
|
+
tabIndex,
|
|
189
|
+
onFocus
|
|
190
|
+
} = _ref2;
|
|
191
|
+
return createElement("div", {
|
|
192
|
+
className: "block-editor-list-view-block__contents-container"
|
|
193
|
+
}, createElement(ListViewBlockContents, {
|
|
194
|
+
block: block,
|
|
195
|
+
onClick: selectBlockInCanvas ? selectEditorBlock : event => {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
},
|
|
198
|
+
onToggleExpanded: toggleExpanded,
|
|
199
|
+
isSelected: isSelected,
|
|
200
|
+
position: position,
|
|
201
|
+
siblingBlockCount: siblingBlockCount,
|
|
202
|
+
level: level,
|
|
203
|
+
ref: ref,
|
|
204
|
+
tabIndex: tabIndex,
|
|
205
|
+
onFocus: onFocus,
|
|
206
|
+
isExpanded: isExpanded,
|
|
207
|
+
selectedClientIds: selectedClientIds,
|
|
208
|
+
preventAnnouncement: preventAnnouncement
|
|
209
|
+
}), createElement("div", {
|
|
210
|
+
className: "block-editor-list-view-block-select-button__description",
|
|
211
|
+
id: descriptionId
|
|
212
|
+
}, blockPositionDescription));
|
|
213
|
+
}), hasRenderedMovers && createElement(Fragment, null, createElement(TreeGridCell, {
|
|
214
|
+
className: moverCellClassName,
|
|
215
|
+
withoutGridItem: true
|
|
216
|
+
}, createElement(TreeGridItem, null, _ref3 => {
|
|
217
|
+
let {
|
|
218
|
+
ref,
|
|
219
|
+
tabIndex,
|
|
220
|
+
onFocus
|
|
221
|
+
} = _ref3;
|
|
222
|
+
return createElement(BlockMoverUpButton, {
|
|
223
|
+
orientation: "vertical",
|
|
224
|
+
clientIds: [clientId],
|
|
225
|
+
ref: ref,
|
|
226
|
+
tabIndex: tabIndex,
|
|
227
|
+
onFocus: onFocus
|
|
228
|
+
});
|
|
229
|
+
}), createElement(TreeGridItem, null, _ref4 => {
|
|
230
|
+
let {
|
|
231
|
+
ref,
|
|
232
|
+
tabIndex,
|
|
233
|
+
onFocus
|
|
234
|
+
} = _ref4;
|
|
235
|
+
return createElement(BlockMoverDownButton, {
|
|
236
|
+
orientation: "vertical",
|
|
237
|
+
clientIds: [clientId],
|
|
238
|
+
ref: ref,
|
|
239
|
+
tabIndex: tabIndex,
|
|
240
|
+
onFocus: onFocus
|
|
241
|
+
});
|
|
242
|
+
}))), showBlockActions && createElement(TreeGridCell, {
|
|
243
|
+
className: listViewBlockSettingsClassName,
|
|
244
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
245
|
+
}, _ref5 => {
|
|
246
|
+
let {
|
|
247
|
+
ref,
|
|
248
|
+
tabIndex,
|
|
249
|
+
onFocus
|
|
250
|
+
} = _ref5;
|
|
251
|
+
return createElement(BlockSettingsDropdown, {
|
|
252
|
+
clientIds: dropdownClientIds,
|
|
253
|
+
icon: moreVertical,
|
|
254
|
+
label: settingsAriaLabel,
|
|
255
|
+
toggleProps: {
|
|
256
|
+
ref,
|
|
257
|
+
className: 'block-editor-list-view-block__menu',
|
|
258
|
+
tabIndex,
|
|
259
|
+
onFocus
|
|
260
|
+
},
|
|
261
|
+
disableOpenOnArrowDown: true,
|
|
262
|
+
__experimentalSelectBlock: updateSelection
|
|
263
|
+
});
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export default memo(ListViewBlock);
|
|
268
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block.js"],"names":["classnames","hasBlockSupport","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","useInstanceId","moreVertical","useState","useRef","useEffect","useCallback","memo","useDispatch","useSelect","sprintf","__","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","getBlockPositionDescription","store","blockEditorStore","useBlockDisplayInformation","useBlockLock","ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","selectBlockInCanvas","cellRef","isHovered","setIsHovered","clientId","isLocked","isContentLocked","forceSelectionContentLock","select","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","className"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,uBAHP;AAIA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,IALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YA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A;AAAjB,KAAF;AAAA,WACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAGJ,iBADb;AAEC,MAAA,IAAI,EAAGjF,YAFR;AAGC,MAAA,KAAK,EAAG2D,iBAHT;AAIC,MAAA,WAAW,EAAG;AACbwB,QAAAA,GADa;AAEbG,QAAAA,SAAS,EAAE,oCAFE;AAGbF,QAAAA,QAHa;AAIbC,QAAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGX;AAX7B,MADC;AAAA,GAJH,CAzFF,CADD;AAiHA;;AAED,eAAerE,IAAI,CAAEgB,aAAF,CAAnB","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"]}
|