@wordpress/block-editor 10.1.1-next.4d3b314fd5.0 → 10.3.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 +14 -0
- package/README.md +41 -0
- package/build/components/block-controls/slot.js +2 -2
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +4 -2
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -5
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-compact.native.js +1 -0
- package/build/components/block-list/block-list-compact.native.js.map +1 -1
- package/build/components/block-list/block.js +72 -14
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +79 -12
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -23
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +9 -6
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-parent-selector/index.js +5 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +5 -4
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/drop-zone.js +85 -0
- package/build/components/block-popover/drop-zone.js.map +1 -0
- package/build/components/block-popover/inbetween.js +3 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +22 -17
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +6 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-preview/live.js +3 -7
- package/build/components/block-preview/live.js.map +1 -1
- package/build/components/block-selection-clearer/index.js +9 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +22 -16
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +18 -42
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +4 -4
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +50 -20
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +15 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +256 -0
- package/build/components/font-sizes/fluid-utils.js.map +1 -0
- package/build/components/font-sizes/index.js +8 -0
- package/build/components/font-sizes/index.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +2 -2
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +151 -78
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/menu.js +14 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +2 -17
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +4 -2
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +2 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/preview-options/index.js +2 -3
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/index.js +17 -0
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +10 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +40 -9
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +98 -57
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +12 -12
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-on-block-drop/types.js +6 -0
- package/build/components/use-on-block-drop/types.js.map +1 -0
- package/build/hooks/align.js +1 -3
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +1 -7
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/font-size.js +60 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/margin.js +6 -5
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +2 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +126 -4
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-typography-props.js +17 -3
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +1 -1
- package/build/hooks/utils.js.map +1 -1
- package/build/store/actions.js +59 -45
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +3 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +36 -18
- package/build/store/reducer.js.map +1 -1
- package/build/utils/math.js +14 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/pre-parse-patterns.js +19 -2
- package/build/utils/pre-parse-patterns.js.map +1 -1
- package/build-module/components/block-controls/slot.js +3 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +7 -3
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-compact.native.js +1 -0
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
- package/build-module/components/block-list/block.js +72 -14
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +80 -13
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +8 -24
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +10 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +5 -5
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +5 -4
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/drop-zone.js +70 -0
- package/build-module/components/block-popover/drop-zone.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +3 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +22 -17
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +6 -9
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-preview/live.js +3 -6
- package/build-module/components/block-preview/live.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js +9 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +25 -19
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +19 -44
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +48 -20
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +15 -3
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +2 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +3 -3
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +245 -0
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -0
- package/build-module/components/font-sizes/index.js +1 -0
- package/build-module/components/font-sizes/index.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +2 -2
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +148 -81
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/menu.js +10 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -17
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +4 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +3 -2
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -3
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +17 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +10 -3
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +40 -10
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +98 -58
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +12 -12
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/types.js +2 -0
- package/build-module/components/use-on-block-drop/types.js.map +1 -0
- package/build-module/hooks/align.js +1 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -6
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/font-size.js +59 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/margin.js +6 -5
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +2 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +124 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +17 -4
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +2 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/store/actions.js +55 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +3 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +36 -19
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/pre-parse-patterns.js +19 -2
- package/build-module/utils/pre-parse-patterns.js.map +1 -1
- package/build-style/style-rtl.css +256 -152
- package/build-style/style.css +256 -152
- package/package.json +28 -29
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-controls/slot.js +3 -3
- package/src/components/block-draggable/draggable-chip.js +4 -2
- package/src/components/block-inspector/index.js +8 -11
- package/src/components/block-list/block-list-compact.native.js +1 -0
- package/src/components/block-list/block.js +111 -7
- package/src/components/block-list/block.native.js +123 -9
- package/src/components/block-list/style.scss +93 -126
- package/src/components/block-list/use-in-between-inserter.js +8 -19
- package/src/components/block-lock/modal.js +12 -7
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-parent-selector/index.js +5 -5
- package/src/components/block-patterns-list/index.js +9 -5
- package/src/components/block-patterns-list/style.scss +7 -3
- package/src/components/block-popover/README.md +8 -0
- package/src/components/block-popover/drop-zone.js +63 -0
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +39 -22
- package/src/components/block-popover/style.scss +17 -1
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/index.js +7 -8
- package/src/components/block-preview/live.js +2 -7
- package/src/components/block-preview/test/index.js +1 -7
- package/src/components/block-selection-clearer/index.js +7 -2
- package/src/components/block-selection-clearer/test/index.js +118 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -18
- package/src/components/block-settings-menu/test/block-mode-toggle.js +17 -17
- package/src/components/block-styles/index.js +26 -49
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +104 -33
- package/src/components/block-switcher/test/index.js +121 -61
- package/src/components/block-toolbar/index.js +4 -6
- package/src/components/block-toolbar/style.scss +38 -14
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/insertion-point.js +42 -17
- package/src/components/block-tools/selected-block-popover.js +14 -1
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +32 -52
- package/src/components/color-palette/test/control.js +11 -15
- package/src/components/colors-gradients/control.js +2 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -4
- package/src/components/colors-gradients/test/control.js +49 -77
- package/src/components/font-sizes/fluid-utils.js +296 -0
- package/src/components/font-sizes/index.js +1 -0
- package/src/components/font-sizes/test/fluid-utils.js +168 -0
- package/src/components/image-editor/use-transform-image.js +2 -2
- package/src/components/image-size-control/test/index.js +47 -60
- package/src/components/index.js +0 -1
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/src/components/inserter/block-patterns-tab.js +232 -98
- package/src/components/inserter/block-types-tab.js +3 -3
- package/src/components/inserter/menu.js +15 -2
- package/src/components/inserter/search-items.js +3 -15
- package/src/components/inserter/style.scss +94 -9
- package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
- package/src/components/inserter/test/search-items.js +4 -0
- package/src/components/inserter-draggable-blocks/index.js +12 -2
- package/src/components/inserter-list-item/style.scss +20 -1
- package/src/components/inspector-controls/slot.js +6 -2
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/use-list-view-drop-zone.js +4 -18
- package/src/components/panel-color-settings/test/index.js +4 -4
- package/src/components/preview-options/index.js +2 -2
- package/src/components/preview-options/style.scss +1 -1
- package/src/components/provider/test/use-block-sync.js +131 -165
- package/src/components/responsive-block-control/test/index.js +77 -122
- package/src/components/rich-text/index.js +22 -0
- package/src/components/spacing-sizes-control/index.js +15 -3
- package/src/components/spacing-sizes-control/spacing-input-control.js +24 -9
- package/src/components/spacing-sizes-control/style.scss +42 -31
- package/src/components/use-block-drop-zone/index.js +136 -79
- package/src/components/use-block-drop-zone/test/index.js +333 -81
- package/src/components/use-on-block-drop/index.js +11 -12
- package/src/components/use-on-block-drop/types.ts +1 -0
- package/src/hooks/align.js +3 -2
- package/src/hooks/align.native.js +5 -8
- package/src/hooks/font-size.js +75 -0
- package/src/hooks/margin.js +5 -4
- package/src/hooks/padding.js +1 -0
- package/src/hooks/style.js +122 -3
- package/src/hooks/test/style.js +206 -1
- package/src/hooks/test/use-typography-props.js +22 -0
- package/src/hooks/use-typography-props.js +18 -3
- package/src/hooks/utils.js +6 -2
- package/src/store/actions.js +20 -12
- package/src/store/defaults.js +3 -0
- package/src/store/reducer.js +35 -28
- package/src/store/test/actions.js +0 -9
- package/src/utils/math.js +17 -0
- package/src/utils/pre-parse-patterns.js +12 -7
- package/build/components/inserter/pattern-panel.js +0 -87
- package/build/components/inserter/pattern-panel.js.map +0 -1
- package/build-module/components/inserter/pattern-panel.js +0 -74
- package/build-module/components/inserter/pattern-panel.js.map +0 -1
- package/src/components/inserter/pattern-panel.js +0 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-parent-selector/index.js"],"names":["getBlockType","store","blocksStore","ToolbarButton","useSelect","useDispatch","__","sprintf","useRef","useBlockDisplayInformation","BlockIcon","useShowMoversGestures","blockEditorStore","BlockParentSelector","selectBlock","toggleBlockHighlight","firstParentClientId","shouldHide","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-parent-selector/index.js"],"names":["getBlockType","store","blocksStore","ToolbarButton","useSelect","useDispatch","__","sprintf","useRef","useBlockDisplayInformation","BlockIcon","useShowMoversGestures","blockEditorStore","BlockParentSelector","selectBlock","toggleBlockHighlight","firstParentClientId","shouldHide","isDistractionFree","select","getBlockName","getBlockParents","getSelectedBlockClientId","getSettings","hasBlockSupport","selectedBlockClientId","parents","_firstParentClientId","length","parentBlockName","_parentBlockType","settings","blockInformation","nodeRef","gestures","showMoversGestures","ref","onChange","isFocused","undefined","title","icon"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,KAAK,IAAIC,WAAhC,QAAmD,mBAAnD;AACA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SAASC,qBAAT,QAAsC,wBAAtC;AACA,SAASV,KAAK,IAAIW,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MACLV,WAAW,CAAEO,gBAAF,CADZ;AAEA,QA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AAvB,CAApB;AACA;;AAP8D,GAAF,CAA9D;;AAUA,MAAKrB,UAAU,IAAID,mBAAmB,KAAKuB,SAA3C,EAAuD;AACtD,WAAO,IAAP;AACA;;AAED,SACC;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,GAAG,EAAGvB,mBAFP;AAGC,IAAA,GAAG,EAAGiB;AAHP,KAIME,kBAJN,GAMC,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,OAAO,EAAG,MAAMrB,WAAW,CAAEE,mBAAF,CAF5B;AAGC,IAAA,KAAK,EAAGT,OAAO;AACd;AACAD,IAAAA,EAAE,CAAE,WAAF,CAFY,EAGd0B,gBAHc,aAGdA,gBAHc,uBAGdA,gBAAgB,CAAEQ,KAHJ,CAHhB;AAQC,IAAA,WAAW,MARZ;AASC,IAAA,IAAI,EAAG,cAAC,SAAD;AAAW,MAAA,IAAI,EAAGR,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAES;AAApC;AATR,IAND,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport { useShowMoversGestures } from '../block-toolbar/utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Block parent selector component, displaying the hierarchy of the\n * current block selection as a single icon to \"go up\" a level.\n *\n * @return {WPComponent} Parent block selector.\n */\nexport default function BlockParentSelector() {\n\tconst { selectBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { firstParentClientId, shouldHide, isDistractionFree } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { hasBlockSupport } = select( blocksStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\t\tconst _firstParentClientId = parents[ parents.length - 1 ];\n\t\t\tconst parentBlockName = getBlockName( _firstParentClientId );\n\t\t\tconst _parentBlockType = getBlockType( parentBlockName );\n\t\t\tconst settings = getSettings();\n\t\t\treturn {\n\t\t\t\tfirstParentClientId: _firstParentClientId,\n\t\t\t\tshouldHide: ! hasBlockSupport(\n\t\t\t\t\t_parentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisDistractionFree: settings.isDistractionFree,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\n\t// Allows highlighting the parent block outline when focusing or hovering\n\t// the parent block selector within the child.\n\tconst nodeRef = useRef();\n\tconst { gestures: showMoversGestures } = useShowMoversGestures( {\n\t\tref: nodeRef,\n\t\tonChange( isFocused ) {\n\t\t\tif ( isFocused && isDistractionFree ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttoggleBlockHighlight( firstParentClientId, isFocused );\n\t\t},\n\t} );\n\n\tif ( shouldHide || firstParentClientId === undefined ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-parent-selector\"\n\t\t\tkey={ firstParentClientId }\n\t\t\tref={ nodeRef }\n\t\t\t{ ...showMoversGestures }\n\t\t>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"block-editor-block-parent-selector__button\"\n\t\t\t\tonClick={ () => selectBlock( firstParentClientId ) }\n\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t/* translators: %s: Name of the block's parent. */\n\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\tblockInformation?.title\n\t\t\t\t) }\n\t\t\t\tshowTooltip\n\t\t\t\ticon={ <BlockIcon icon={ blockInformation?.icon } /> }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -29,7 +29,8 @@ function BlockPattern(_ref) {
|
|
|
29
29
|
const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
|
|
30
30
|
return createElement(InserterDraggableBlocks, {
|
|
31
31
|
isEnabled: isDraggable,
|
|
32
|
-
blocks: blocks
|
|
32
|
+
blocks: blocks,
|
|
33
|
+
isPattern: !!pattern
|
|
33
34
|
}, _ref2 => {
|
|
34
35
|
let {
|
|
35
36
|
draggable,
|
|
@@ -38,8 +39,6 @@ function BlockPattern(_ref) {
|
|
|
38
39
|
} = _ref2;
|
|
39
40
|
return createElement("div", {
|
|
40
41
|
className: "block-editor-block-patterns-list__list-item",
|
|
41
|
-
"aria-label": pattern.title,
|
|
42
|
-
"aria-describedby": pattern.description ? descriptionId : undefined,
|
|
43
42
|
draggable: draggable,
|
|
44
43
|
onDragStart: onDragStart,
|
|
45
44
|
onDragEnd: onDragEnd
|
|
@@ -48,7 +47,9 @@ function BlockPattern(_ref) {
|
|
|
48
47
|
as: "div"
|
|
49
48
|
}, composite, {
|
|
50
49
|
className: "block-editor-block-patterns-list__item",
|
|
51
|
-
onClick: () => onClick(pattern, blocks)
|
|
50
|
+
onClick: () => onClick(pattern, blocks),
|
|
51
|
+
"aria-label": pattern.title,
|
|
52
|
+
"aria-describedby": pattern.description ? descriptionId : undefined
|
|
52
53
|
}), createElement(BlockPreview, {
|
|
53
54
|
blocks: blocks,
|
|
54
55
|
viewportWidth: viewportWidth
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"names":["VisuallyHidden","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useInstanceId","__","BlockPreview","InserterDraggableBlocks","BlockPattern","isDraggable","pattern","onClick","composite","blocks","viewportWidth","instanceId","descriptionId","draggable","onDragStart","onDragEnd","title","description","undefined","BlockPatternPlaceholder","BlockPatternList","blockPatterns","shownPatterns","onClickPattern","orientation","label","map","isShown","includes","name"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,mBAAmB,IAAIC,SAFxB,EAGCC,2BAA2B,IAAIC,iBAHhC,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,uBALP;AAMA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,uBAAP,MAAoC,8BAApC;;AAEA,SAASC,YAAT,OAAsE;AAAA,MAA/C;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,OAAxB;AAAiCC,IAAAA;AAAjC,GAA+C;AACrE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAA4BJ,OAAlC;AACA,QAAMK,UAAU,GAAGX,aAAa,CAAEI,YAAF,CAAhC;AACA,QAAMQ,aAAa,GAAI,sDAAsDD,UAAY,EAAzF;AAEA,SACC,cAAC,uBAAD;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"names":["VisuallyHidden","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useInstanceId","__","BlockPreview","InserterDraggableBlocks","BlockPattern","isDraggable","pattern","onClick","composite","blocks","viewportWidth","instanceId","descriptionId","draggable","onDragStart","onDragEnd","title","description","undefined","BlockPatternPlaceholder","BlockPatternList","blockPatterns","shownPatterns","onClickPattern","orientation","label","map","isShown","includes","name"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,mBAAmB,IAAIC,SAFxB,EAGCC,2BAA2B,IAAIC,iBAHhC,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,u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,KADX,CAfD,EAkBG,CAAC,CAAEV,OAAO,CAACW,WAAX,IACD,cAAC,cAAD;AAAgB,MAAA,EAAE,EAAGL;AAArB,OACGN,OAAO,CAACW,WADX,CAnBF,CAND,CADC;AAAA,GALH,CADD;AAyCA;;AAED,SAASE,uBAAT,GAAmC;AAClC,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,IADD;AAGA;;AAED,SAASC,gBAAT,QAOI;AAAA,MAPuB;AAC1Bf,IAAAA,WAD0B;AAE1BgB,IAAAA,aAF0B;AAG1BC,IAAAA,aAH0B;AAI1BC,IAAAA,cAJ0B;AAK1BC,IAAAA,WAL0B;AAM1BC,IAAAA,KAAK,GAAGxB,EAAE,CAAE,gBAAF;AANgB,GAOvB;AACH,QAAMO,SAAS,GAAGX,iBAAiB,CAAE;AAAE2B,IAAAA;AAAF,GAAF,CAAnC;AACA,SACC,cAAC,SAAD,eACMhB,SADN;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,SAAS,EAAC,kCAHX;AAIC,kBAAaiB;AAJd,MAMGJ,aAAa,CAACK,GAAd,CAAqBpB,OAAF,IAAe;AACnC,UAAMqB,OAAO,GAAGL,aAAa,CAACM,QAAd,CAAwBtB,OAAxB,CAAhB;AACA,WAAOqB,OAAO,GACb,cAAC,YAAD;AACC,MAAA,GAAG,EAAGrB,OAAO,CAACuB,IADf;AAEC,MAAA,OAAO,EAAGvB,OAFX;AAGC,MAAA,OAAO,EAAGiB,cAHX;AAIC,MAAA,WAAW,EAAGlB,WAJf;AAKC,MAAA,SAAS,EAAGG;AALb,MADa,GASb,cAAC,uBAAD;AAAyB,MAAA,GAAG,EAAGF,OAAO,CAACuB;AAAvC,MATD;AAWA,GAbC,CANH,CADD;AAuBA;;AAED,eAAeT,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tVisuallyHidden,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockPreview from '../block-preview';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction BlockPattern( { isDraggable, pattern, onClick, composite } ) {\n\tconst { blocks, viewportWidth } = pattern;\n\tconst instanceId = useInstanceId( BlockPattern );\n\tconst descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable }\n\t\t\tblocks={ blocks }\n\t\t\tisPattern={ !! pattern }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-block-patterns-list__list-item\"\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t>\n\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\tas=\"div\"\n\t\t\t\t\t\t{ ...composite }\n\t\t\t\t\t\tclassName=\"block-editor-block-patterns-list__item\"\n\t\t\t\t\t\tonClick={ () => onClick( pattern, blocks ) }\n\t\t\t\t\t\taria-label={ pattern.title }\n\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\tpattern.description ? descriptionId : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div className=\"block-editor-block-patterns-list__item-title\">\n\t\t\t\t\t\t\t{ pattern.title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{ !! pattern.description && (\n\t\t\t\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t\t\t\t{ pattern.description }\n\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</CompositeItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nfunction BlockPatternPlaceholder() {\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-list__item is-placeholder\" />\n\t);\n}\n\nfunction BlockPatternList( {\n\tisDraggable,\n\tblockPatterns,\n\tshownPatterns,\n\tonClickPattern,\n\torientation,\n\tlabel = __( 'Block Patterns' ),\n} ) {\n\tconst composite = useCompositeState( { orientation } );\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-block-patterns-list\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ blockPatterns.map( ( pattern ) => {\n\t\t\t\tconst isShown = shownPatterns.includes( pattern );\n\t\t\t\treturn isShown ? (\n\t\t\t\t\t<BlockPattern\n\t\t\t\t\t\tkey={ pattern.name }\n\t\t\t\t\t\tpattern={ pattern }\n\t\t\t\t\t\tonClick={ onClickPattern }\n\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockPatternPlaceholder key={ pattern.name } />\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default BlockPatternList;\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { useReducedMotion } from '@wordpress/compose';
|
|
8
|
+
import { __unstableMotion as motion } from '@wordpress/components';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import BlockPopover from './index';
|
|
15
|
+
const animateVariants = {
|
|
16
|
+
hide: {
|
|
17
|
+
opacity: 0,
|
|
18
|
+
scaleY: 0.75
|
|
19
|
+
},
|
|
20
|
+
show: {
|
|
21
|
+
opacity: 1,
|
|
22
|
+
scaleY: 1
|
|
23
|
+
},
|
|
24
|
+
exit: {
|
|
25
|
+
opacity: 0,
|
|
26
|
+
scaleY: 0.9
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function BlockDropZonePopover(_ref) {
|
|
31
|
+
let {
|
|
32
|
+
__unstablePopoverSlot,
|
|
33
|
+
__unstableContentRef
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
clientId
|
|
37
|
+
} = useSelect(select => {
|
|
38
|
+
const {
|
|
39
|
+
getBlockOrder,
|
|
40
|
+
getBlockInsertionPoint
|
|
41
|
+
} = select(blockEditorStore);
|
|
42
|
+
const insertionPoint = getBlockInsertionPoint();
|
|
43
|
+
const order = getBlockOrder(insertionPoint.rootClientId);
|
|
44
|
+
|
|
45
|
+
if (!order.length) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
clientId: order[insertionPoint.index]
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
const reducedMotion = useReducedMotion();
|
|
54
|
+
return createElement(BlockPopover, {
|
|
55
|
+
clientId: clientId,
|
|
56
|
+
__unstableCoverTarget: true,
|
|
57
|
+
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
58
|
+
__unstableContentRef: __unstableContentRef,
|
|
59
|
+
className: "block-editor-block-popover__drop-zone"
|
|
60
|
+
}, createElement(motion.div, {
|
|
61
|
+
"data-testid": "block-popover-drop-zone",
|
|
62
|
+
initial: reducedMotion ? animateVariants.show : animateVariants.hide,
|
|
63
|
+
animate: animateVariants.show,
|
|
64
|
+
exit: reducedMotion ? animateVariants.show : animateVariants.exit,
|
|
65
|
+
className: "block-editor-block-popover__drop-zone-foreground"
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default BlockDropZonePopover;
|
|
70
|
+
//# sourceMappingURL=drop-zone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/drop-zone.js"],"names":["useSelect","useReducedMotion","__unstableMotion","motion","store","blockEditorStore","BlockPopover","animateVariants","hide","opacity","scaleY","show","exit","BlockDropZonePopover","__unstablePopoverSlot","__unstableContentRef","clientId","select","getBlockOrder","getBlockInsertionPoint","insertionPoint","order","rootClientId","length","index","reducedMotion"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,YAAP,MAAyB,SAAzB;AAEA,MAAMC,eAAe,GAAG;AACvBC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB,GADiB;AAEvBC,EAAAA,IAAI,EAAE;AAAEF,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB,GAFiB;AAGvBE,EAAAA,IAAI,EAAE;AAAEH,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB;AAHiB,CAAxB;;AAMA,SAASG,oBAAT,OAGI;AAAA,MAH2B;AAC9BC,IAAAA,qBAD8B;AAE9BC,IAAAA;AAF8B,GAG3B;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAehB,SAAS,CAAIiB,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QACLF,MAAM,CAAEZ,gBAAF,CADP;AAEA,UAAMe,cAAc,GAAGD,sBAAsB,EAA7C;AACA,UAAME,KAAK,GAAGH,aAAa,CAAEE,cAAc,CAACE,YAAjB,CAA3B;;AAEA,QAAK,CAAED,KAAK,CAACE,MAAb,EAAsB;AACrB,aAAO,EAAP;AACA;;AAED,WAAO;AACNP,MAAAA,QAAQ,EAAEK,KAAK,CAAED,cAAc,CAACI,KAAjB;AADT,KAAP;AAGA,GAb6B,EAa3B,EAb2B,CAA9B;AAcA,QAAMC,aAAa,GAAGxB,gBAAgB,EAAtC;AAEA,SACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGe,QADZ;AAEC,IAAA,qBAAqB,MAFtB;AAGC,IAAA,qBAAqB,EAAGF,qBAHzB;AAIC,IAAA,oBAAoB,EAAGC,oBAJxB;AAKC,IAAA,SAAS,EAAC;AALX,KAOC,cAAC,MAAD,CAAQ,GAAR;AACC,mBAAY,yBADb;AAEC,IAAA,OAAO,EACNU,aAAa,GAAGlB,eAAe,CAACI,IAAnB,GAA0BJ,eAAe,CAACC,IAHzD;AAKC,IAAA,OAAO,EAAGD,eAAe,CAACI,IAL3B;AAMC,IAAA,IAAI,EACHc,aAAa,GAAGlB,eAAe,CAACI,IAAnB,GAA0BJ,eAAe,CAACK,IAPzD;AASC,IAAA,SAAS,EAAC;AATX,IAPD,CADD;AAqBA;;AAED,eAAeC,oBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from './index';\n\nconst animateVariants = {\n\thide: { opacity: 0, scaleY: 0.75 },\n\tshow: { opacity: 1, scaleY: 1 },\n\texit: { opacity: 0, scaleY: 0.9 },\n};\n\nfunction BlockDropZonePopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { clientId } = useSelect( ( select ) => {\n\t\tconst { getBlockOrder, getBlockInsertionPoint } =\n\t\t\tselect( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tclientId: order[ insertionPoint.index ],\n\t\t};\n\t}, [] );\n\tconst reducedMotion = useReducedMotion();\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\tclassName=\"block-editor-block-popover__drop-zone\"\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tdata-testid=\"block-popover-drop-zone\"\n\t\t\t\tinitial={\n\t\t\t\t\treducedMotion ? animateVariants.show : animateVariants.hide\n\t\t\t\t}\n\t\t\t\tanimate={ animateVariants.show }\n\t\t\t\texit={\n\t\t\t\t\treducedMotion ? animateVariants.show : animateVariants.exit\n\t\t\t\t}\n\t\t\t\tclassName=\"block-editor-block-popover__drop-zone-foreground\"\n\t\t\t/>\n\t\t</BlockPopover>\n\t);\n}\n\nexport default BlockDropZonePopover;\n"]}
|
|
@@ -178,7 +178,9 @@ function BlockPopoverInbetween(_ref) {
|
|
|
178
178
|
|
|
179
179
|
previousElement.ownerDocument.defaultView.addEventListener('resize', forcePopoverRecompute);
|
|
180
180
|
return () => {
|
|
181
|
-
|
|
181
|
+
var _previousElement$owne;
|
|
182
|
+
|
|
183
|
+
(_previousElement$owne = previousElement.ownerDocument.defaultView) === null || _previousElement$owne === void 0 ? void 0 : _previousElement$owne.removeEventListener('resize', forcePopoverRecompute);
|
|
182
184
|
};
|
|
183
185
|
}, [previousElement]); // If there's either a previous or a next element, show the inbetween popover.
|
|
184
186
|
// Note that drag and drop uses the inbetween popover to show the drop indicator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["classnames","useSelect","useMemo","createContext","useReducer","useLayoutEffect","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,UAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;AAEA,OAAO,MAAMC,qBAAqB,GAAGb,aAAa,EAA3C;;AAEP,SAASc,qBAAT,OAOI;AAAA,MAP4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,YAF+B;AAG/BC,IAAAA,QAH+B;AAI/BC,IAAAA,qBAJ+B;AAK/BC,IAAAA,oBAL+B;AAM/B,OAAGC;AAN4B,GAO5B;AACH;AACA,QAAM,CAAEC,uBAAF,EAA2BC,qBAA3B,IAAqDrB,UAAU,EACpE;AACEsB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IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBS;AAV7B,KAWML,KAXN;AAYC,IAAA,SAAS,EAAGvB,UAAU,CACrB,4BADqB,EAErB,uCAFqB,EAGrBuB,KAAK,CAACuC,SAHe,CAZvB;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC;AAnBX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGlB,QAJH,CArBD,CADD;AA8BA;AACA;;AAED,eAAeH,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\tconst style = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["classnames","useSelect","useMemo","createContext","useReducer","useLayoutEffect","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,UAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;AAEA,OAAO,MAAMC,qBAAqB,GAAGb,aAAa,EAA3C;;AAEP,SAASc,qBAAT,OAOI;AAAA,MAP4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,YAF+B;AAG/BC,IAAAA,QAH+B;AAI/BC,IAAAA,qBAJ+B;AAK/BC,IAAAA,oBAL+B;AAM/B,OAAGC;AAN4B,GAO5B;AACH;AACA,QAAM,CAAEC,uBAAF,EAA2BC,qBAA3B,IAAqDrB,UAAU,EACpE;AACEsB,EAAAA,CAAF,IAAS,CAAEA,CAAC,GAAG,CAAN,IAAYb,6BAF+C,EAGpE,CAHoE,CAArE;AAMA,QAAM;AAAEc,IAAAA,WAAF;AAAeC,IAAAA,YAAf;AA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GrBuB,KAAK,CAACuC,SAHe,CAZvB;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC;AAnBX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGlB,QAJH,CArBD,CADD;AA8BA;AACA;;AAED,eAAeH,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\tconst style = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"]}
|
|
@@ -29,23 +29,13 @@ function BlockPopover(_ref, ref) {
|
|
|
29
29
|
__unstableCoverTarget = false,
|
|
30
30
|
__unstablePopoverSlot,
|
|
31
31
|
__unstableContentRef,
|
|
32
|
+
shift = true,
|
|
32
33
|
...props
|
|
33
34
|
} = _ref;
|
|
34
35
|
const selectedElement = useBlockElement(clientId);
|
|
35
36
|
const lastSelectedElement = useBlockElement(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
|
|
36
37
|
const mergedRefs = useMergeRefs([ref, usePopoverScroll(__unstableContentRef)]);
|
|
37
|
-
const
|
|
38
|
-
if (!selectedElement || lastSelectedElement !== selectedElement) {
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
position: 'absolute',
|
|
44
|
-
width: selectedElement.offsetWidth,
|
|
45
|
-
height: selectedElement.offsetHeight
|
|
46
|
-
};
|
|
47
|
-
}, [selectedElement, lastSelectedElement, __unstableRefreshSize]);
|
|
48
|
-
const [popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor] = useReducer( // Module is there to make sure that the counter doesn't overflow.
|
|
38
|
+
const [popoverDimensionsRecomputeCounter, forceRecomputePopoverDimensions] = useReducer( // Module is there to make sure that the counter doesn't overflow.
|
|
49
39
|
s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0); // When blocks are moved up/down, they are animated to their new position by
|
|
50
40
|
// updating the `transform` property manually (i.e. without using CSS
|
|
51
41
|
// transitions or animations). The animation, which can also scroll the block
|
|
@@ -59,7 +49,7 @@ function BlockPopover(_ref, ref) {
|
|
|
59
49
|
return;
|
|
60
50
|
}
|
|
61
51
|
|
|
62
|
-
const observer = new window.MutationObserver(
|
|
52
|
+
const observer = new window.MutationObserver(forceRecomputePopoverDimensions);
|
|
63
53
|
observer.observe(selectedElement, {
|
|
64
54
|
attributes: true
|
|
65
55
|
});
|
|
@@ -67,11 +57,25 @@ function BlockPopover(_ref, ref) {
|
|
|
67
57
|
observer.disconnect();
|
|
68
58
|
};
|
|
69
59
|
}, [selectedElement]);
|
|
60
|
+
const style = useMemo(() => {
|
|
61
|
+
if ( // popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
62
|
+
// than 0. This check is only there to satisfy the correctness of the
|
|
63
|
+
// exhaustive-deps rule for the `useMemo` hook.
|
|
64
|
+
popoverDimensionsRecomputeCounter < 0 || !selectedElement || lastSelectedElement !== selectedElement) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
width: selectedElement.offsetWidth,
|
|
71
|
+
height: selectedElement.offsetHeight
|
|
72
|
+
};
|
|
73
|
+
}, [selectedElement, lastSelectedElement, __unstableRefreshSize, popoverDimensionsRecomputeCounter]);
|
|
70
74
|
const popoverAnchor = useMemo(() => {
|
|
71
|
-
if ( //
|
|
75
|
+
if ( // popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
72
76
|
// than 0. This check is only there to satisfy the correctness of the
|
|
73
77
|
// exhaustive-deps rule for the `useMemo` hook.
|
|
74
|
-
|
|
78
|
+
popoverDimensionsRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement) {
|
|
75
79
|
return undefined;
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -96,7 +100,7 @@ function BlockPopover(_ref, ref) {
|
|
|
96
100
|
|
|
97
101
|
ownerDocument: selectedElement.ownerDocument
|
|
98
102
|
};
|
|
99
|
-
}, [bottomClientId, lastSelectedElement, selectedElement,
|
|
103
|
+
}, [bottomClientId, lastSelectedElement, selectedElement, popoverDimensionsRecomputeCounter]);
|
|
100
104
|
|
|
101
105
|
if (!selectedElement || bottomClientId && !lastSelectedElement) {
|
|
102
106
|
return null;
|
|
@@ -110,9 +114,10 @@ function BlockPopover(_ref, ref) {
|
|
|
110
114
|
// otherwise render in place (not in the default popover slot).
|
|
111
115
|
,
|
|
112
116
|
__unstableSlotName: __unstablePopoverSlot || null,
|
|
117
|
+
placement: "top-start",
|
|
113
118
|
resize: false,
|
|
114
119
|
flip: false,
|
|
115
|
-
shift:
|
|
120
|
+
shift: shift
|
|
116
121
|
}, props, {
|
|
117
122
|
className: classnames('block-editor-block-popover', props.className)
|
|
118
123
|
}), __unstableCoverTarget && createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["classnames","useMergeRefs","Popover","forwardRef","useMemo","useReducer","useLayoutEffect","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["classnames","useMergeRefs","Popover","forwardRef","useMemo","useReducer","useLayoutEffect","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","shift","props","selectedElement","lastSelectedElement","mergedRefs","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","s","observer","window","MutationObserver","observe","attributes","disconnect","style","position","width","offsetWidth","height","offsetHeight","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SACCC,UADD,EAECC,OAFD,EAGCC,UAHD,EAICC,eAJD,QAKO,oBALP;AAOA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;;AAEA,SAASC,YAAT,OAYCC,GAZD,EAaE;AAAA,MAZD;AACCC,IAAAA,QADD;AAECC,IAAAA,cAFD;AAGCC,IAAAA,QAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,qBAAqB,GAAG,KALzB;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AAa,EAAEhC,eAAe,CAACgC;AA/BzB,KAAP;AAiCA,GA7C4B,EA6C1B,CACFxC,cADE,EAEFS,mBAFE,EAGFD,eAHE,EAIFG,iCAJE,CA7C0B,CAA7B;;AAoDA,MAAK,CAAEH,eAAF,IAAuBR,cAAc,IAAI,CAAES,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,GAAG,EAAGC,UADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,MAAM,EAAGgB,aAJV,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAGtB,qBAAqB,IAAI,IAP/C;AAQC,IAAA,SAAS,EAAC,WARX;AASC,IAAA,MAAM,EAAG,KATV;AAUC,IAAA,IAAI,EAAG,KAVR;AAWC,IAAA,KAAK,EAAGE;AAXT,KAYMC,KAZN;AAaC,IAAA,SAAS,EAAGvB,UAAU,CACrB,4BADqB,EAErBuB,KAAK,CAACkC,SAFe;AAbvB,MAkBGtC,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGiB;AAAb,KAAuBnB,QAAvB,CAlB5B,EAmBG,CAAEE,qBAAF,IAA2BF,QAnB9B,CADD;AAuBA;;AAED,eAAed,UAAU,CAAEU,YAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst style = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\tlastSelectedElement !== selectedElement\n\t\t) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [\n\t\tselectedElement,\n\t\tlastSelectedElement,\n\t\t__unstableRefreshSize,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"]}
|
|
@@ -4,10 +4,10 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { Disabled } from '@wordpress/components';
|
|
8
7
|
import { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';
|
|
9
8
|
import { useSelect } from '@wordpress/data';
|
|
10
9
|
import { useMemo } from '@wordpress/element';
|
|
10
|
+
import { Disabled } from '@wordpress/components';
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/auto.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/auto.js"],"names":["useResizeObserver","pure","useRefEffect","useSelect","useMemo","Disabled","BlockList","Iframe","EditorStyles","__unstablePresetDuotoneFilter","PresetDuotoneFilter","store","MemoizedBlockList","MAX_HEIGHT","ScaledBlockPreview","viewportWidth","containerWidth","__experimentalPadding","__experimentalMinHeight","contentResizeListener","height","contentHeight","styles","assets","duotone","select","settings","getSettings","__unstableResolvedAssets","__experimentalFeatures","color","editorStyles","css","__unstableType","svgFilters","default","theme","scale","transform","maxHeight","undefined","minHeight","bodyElement","ownerDocument","documentElement","classList","add","style","position","width","padding","boxSizing","pointerEvents","map","preset","slug","AutoBlockPreview","props","containerResizeListener"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EAA4BC,IAA5B,EAAkCC,YAAlC,QAAsD,oBAAtD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,6BAA6B,IAAIC,mBAA1C,QAAqE,0BAArE;AACA,SAASC,KAAT,QAAsB,aAAtB,C,CAEA;;AACA,IAAIC,iBAAJ;AAEA,MAAMC,UAAU,GAAG,IAAnB;;AAEA,SAASC,kBAAT,OAKI;AAAA,MALyB;AAC5BC,IAAAA,aAD4B;AAE5BC,IAAAA,cAF4B;AAG5BC,IAAAA,qBAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,QAAM,CAAEC,qBAAF,EAAyB;AAAEC,IAAAA,MAAM,EAAEC;AAAV,GAAzB,IACLrB,iBAAiB,EADlB;AAEA,QAAM;AAAEsB,IAAAA,MAAF;AAAUC,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,MAA8BrB,SAAS,CAAIsB,MAAF,IAAc;AAAA;;AAC5D,UAAMC,QAAQ,GAAGD,MAAM,CAAEd,KAAF,CAAN,CAAgBgB,WAAhB,EAAjB;AACA,WAAO;AACNL,MAAAA,MAAM,EAAEI,QAAQ,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A,MADV;AAEC,IAAA,GAAG,EAAGA,MAAM,CAACC;AAFd,IADD,CAtCF,EA6CC,cAAC,iBAAD;AAAmB,IAAA,cAAc,EAAG;AAApC,IA7CD,CAVD,CADD;AA4DA;;AAED,eAAe,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AACjD,QAAM,CAAEC,uBAAF,EAA2B;AAAET,IAAAA,KAAK,EAAEjC;AAAT,GAA3B,IACLhB,iBAAiB,EADlB;AAGA,SACC,8BACC;AAAK,IAAA,KAAK,EAAG;AAAEgD,MAAAA,QAAQ,EAAE,UAAZ;AAAwBC,MAAAA,KAAK,EAAE,MAA/B;AAAuC7B,MAAAA,MAAM,EAAE;AAA/C;AAAb,KACGsC,uBADH,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAC,CAAE1C,cAAH,IACD,cAAC,kBAAD,eACMyC,KADN;AAEC,IAAA,cAAc,EAAGzC;AAFlB,KAFF,CAJD,CADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { Disabled } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport Iframe from '../iframe';\nimport EditorStyles from '../editor-styles';\nimport { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '../../components/duotone';\nimport { store } from '../../store';\n\n// This is used to avoid rendering the block list if the sizes change.\nlet MemoizedBlockList;\n\nconst MAX_HEIGHT = 2000;\n\nfunction ScaledBlockPreview( {\n\tviewportWidth,\n\tcontainerWidth,\n\t__experimentalPadding,\n\t__experimentalMinHeight,\n} ) {\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst { styles, assets, duotone } = useSelect( ( select ) => {\n\t\tconst settings = select( store ).getSettings();\n\t\treturn {\n\t\t\tstyles: settings.styles,\n\t\t\tassets: settings.__unstableResolvedAssets,\n\t\t\tduotone: settings.__experimentalFeatures?.color?.duotone,\n\t\t};\n\t}, [] );\n\n\t// Avoid scrollbars for pattern previews.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{height:auto;overflow:hidden;}',\n\t\t\t\t\t__unstableType: 'presets',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\tconst svgFilters = useMemo( () => {\n\t\treturn [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];\n\t}, [ duotone ] );\n\n\t// Initialize on render instead of module top level, to avoid circular dependency issues.\n\tMemoizedBlockList = MemoizedBlockList || pure( BlockList );\n\n\tconst scale = containerWidth / viewportWidth;\n\treturn (\n\t\t<Disabled\n\t\t\tclassName=\"block-editor-block-preview__content\"\n\t\t\tstyle={ {\n\t\t\t\ttransform: `scale(${ scale })`,\n\t\t\t\theight: contentHeight * scale,\n\t\t\t\tmaxHeight:\n\t\t\t\t\tcontentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,\n\t\t\t\tminHeight: __experimentalMinHeight,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\t\tassets={ assets }\n\t\t\t\tcontentRef={ useRefEffect( ( bodyElement ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\townerDocument: { documentElement },\n\t\t\t\t\t} = bodyElement;\n\t\t\t\t\tdocumentElement.classList.add(\n\t\t\t\t\t\t'block-editor-block-preview__content-iframe'\n\t\t\t\t\t);\n\t\t\t\t\tdocumentElement.style.position = 'absolute';\n\t\t\t\t\tdocumentElement.style.width = '100%';\n\t\t\t\t\tbodyElement.style.padding = __experimentalPadding + 'px';\n\n\t\t\t\t\t// Necessary for contentResizeListener to work.\n\t\t\t\t\tbodyElement.style.boxSizing = 'border-box';\n\t\t\t\t\tbodyElement.style.position = 'absolute';\n\t\t\t\t\tbodyElement.style.width = '100%';\n\t\t\t\t}, [] ) }\n\t\t\t\taria-hidden\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\twidth: viewportWidth,\n\t\t\t\t\theight: contentHeight,\n\t\t\t\t\tpointerEvents: 'none',\n\t\t\t\t\t// This is a catch-all max-height for patterns.\n\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/38175.\n\t\t\t\t\tmaxHeight: MAX_HEIGHT,\n\t\t\t\t\tminHeight:\n\t\t\t\t\t\tscale !== 0 && scale < 1 && __experimentalMinHeight\n\t\t\t\t\t\t\t? __experimentalMinHeight / scale\n\t\t\t\t\t\t\t: __experimentalMinHeight,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ contentResizeListener }\n\t\t\t\t{\n\t\t\t\t\t/* Filters need to be rendered before children to avoid Safari rendering issues. */\n\t\t\t\t\tsvgFilters.map( ( preset ) => (\n\t\t\t\t\t\t<PresetDuotoneFilter\n\t\t\t\t\t\t\tpreset={ preset }\n\t\t\t\t\t\t\tkey={ preset.slug }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) )\n\t\t\t\t}\n\t\t\t\t<MemoizedBlockList renderAppender={ false } />\n\t\t\t</Iframe>\n\t\t</Disabled>\n\t);\n}\n\nexport default function AutoBlockPreview( props ) {\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\n\treturn (\n\t\t<>\n\t\t\t<div style={ { position: 'relative', width: '100%', height: 0 } }>\n\t\t\t\t{ containerResizeListener }\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-block-preview__container\">\n\t\t\t\t{ !! containerWidth && (\n\t\t\t\t\t<ScaledBlockPreview\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\tcontainerWidth={ containerWidth }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -31,12 +31,9 @@ export function BlockPreview(_ref) {
|
|
|
31
31
|
__experimentalMinHeight
|
|
32
32
|
} = _ref;
|
|
33
33
|
const originalSettings = useSelect(select => select(blockEditorStore).getSettings(), []);
|
|
34
|
-
const settings = useMemo(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_settings.__experimentalBlockPatterns = [];
|
|
38
|
-
return _settings;
|
|
39
|
-
}, [originalSettings]);
|
|
34
|
+
const settings = useMemo(() => ({ ...originalSettings,
|
|
35
|
+
__unstableIsPreviewMode: true
|
|
36
|
+
}), [originalSettings]);
|
|
40
37
|
const renderedBlocks = useMemo(() => castArray(blocks), [blocks]);
|
|
41
38
|
|
|
42
39
|
if (!blocks || blocks.length === 0) {
|
|
@@ -91,11 +88,11 @@ export function useBlockPreview(_ref2) {
|
|
|
91
88
|
__experimentalLayout
|
|
92
89
|
} = _ref2;
|
|
93
90
|
const originalSettings = useSelect(select => select(blockEditorStore).getSettings(), []);
|
|
94
|
-
const disabledRef = useDisabled();
|
|
95
|
-
const ref = useMergeRefs([props.ref, disabledRef]);
|
|
96
91
|
const settings = useMemo(() => ({ ...originalSettings,
|
|
97
|
-
|
|
92
|
+
__unstableIsPreviewMode: true
|
|
98
93
|
}), [originalSettings]);
|
|
94
|
+
const disabledRef = useDisabled();
|
|
95
|
+
const ref = useMergeRefs([props.ref, disabledRef]);
|
|
99
96
|
const renderedBlocks = useMemo(() => castArray(blocks), [blocks]);
|
|
100
97
|
const children = createElement(BlockEditorProvider, {
|
|
101
98
|
value: renderedBlocks,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"names":["castArray","classnames","useDisabled","useMergeRefs","useSelect","memo","useMemo","BlockEditorProvider","LiveBlockPreview","AutoHeightBlockPreview","store","blockEditorStore","BlockListItems","BlockPreview","blocks","__experimentalPadding","viewportWidth","__experimentalLive","__experimentalOnClick","__experimentalMinHeight","originalSettings","select","getSettings","settings","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"names":["castArray","classnames","useDisabled","useMergeRefs","useSelect","memo","useMemo","BlockEditorProvider","LiveBlockPreview","AutoHeightBlockPreview","store","blockEditorStore","BlockListItems","BlockPreview","blocks","__experimentalPadding","viewportWidth","__experimentalLive","__experimentalOnClick","__experimentalMinHeight","originalSettings","select","getSettings","settings","__unstableIsPreviewMode","renderedBlocks","length","useBlockPreview","props","__experimentalLayout","disabledRef","ref","children","className"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,oBAA1C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,IAAT,EAAeC,OAAf,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,aAAhC;AACA,OAAOC,gBAAP,MAA6B,QAA7B;AACA,OAAOC,sBAAP,MAAmC,QAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,cAAT,QAA+B,eAA/B;AAEA,OAAO,SAASC,YAAT,OAOH;AAAA,MAP0B;AAC7BC,IAAAA,MAD6B;AAE7BC,IAAAA,qBAAqB,GAAG,CAFK;AAG7BC,IAAAA,aAAa,GAAG,IAHa;AAI7BC,IAAAA,kBAAkB,GAAG,KAJQ;AAK7BC,IAAAA,qBAL6B;AAM7BC,IAAAA;AAN6B,GAO1B;AACH,QAAMC,gBAAgB,GAAGhB,SAAS,CAC/BiB,MAAF,IAAcA,MAAM,CAAEV,gBAAF,CAAN,CAA2BW,WAA3B,EADmB,EAEjC,EAFiC,CAAlC;AAIA,QAAMC,QAAQ,GAAGjB,OAAO,CACvB,OAAQ,EAAE,GAAGc,gBAAL;AAAuBI,IAAAA,uBAAuB,EAAE;AAAhD,G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K,CAACG,GAAR,EAAaD,WAAb,CAAF,CAAxB;AACA,QAAML,cAAc,GAAGnB,OAAO,CAAE,MAAMN,SAAS,CAAEc,MAAF,CAAjB,EAA6B,CAAEA,MAAF,CAA7B,CAA9B;AAEA,QAAMkB,QAAQ,GACb,cAAC,mBAAD;AAAqB,IAAA,KAAK,EAAGP,cAA7B;AAA8C,IAAA,QAAQ,EAAGF;AAAzD,KACC,cAAC,cAAD;AACC,IAAA,cAAc,EAAG,KADlB;AAEC,IAAA,oBAAoB,EAAGM;AAFxB,IADD,CADD;AASA,SAAO,EACN,GAAGD,KADG;AAENG,IAAAA,GAFM;AAGNE,IAAAA,SAAS,EAAEhC,UAAU,CACpB2B,KAAK,CAACK,SADc,EAEpB,0CAFoB,EAGpB,qBAHoB,CAHf;AAQND,IAAAA,QAAQ,EAAElB,MAAM,SAAN,IAAAA,MAAM,WAAN,IAAAA,MAAM,CAAEY,MAAR,GAAiBM,QAAjB,GAA4B;AARhC,GAAP;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockEditorProvider from '../provider';\nimport LiveBlockPreview from './live';\nimport AutoHeightBlockPreview from './auto';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nexport function BlockPreview( {\n\tblocks,\n\t__experimentalPadding = 0,\n\tviewportWidth = 1200,\n\t__experimentalLive = false,\n\t__experimentalOnClick,\n\t__experimentalMinHeight,\n} ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo( () => castArray( blocks ), [ blocks ] );\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<BlockEditorProvider value={ renderedBlocks } settings={ settings }>\n\t\t\t{ __experimentalLive ? (\n\t\t\t\t<LiveBlockPreview onClick={ __experimentalOnClick } />\n\t\t\t) : (\n\t\t\t\t<AutoHeightBlockPreview\n\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t__experimentalPadding={ __experimentalPadding }\n\t\t\t\t\t__experimentalMinHeight={ __experimentalMinHeight }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.__experimentalLayout Layout settings to be used in the preview.\n *\n */\nexport function useBlockPreview( {\n\tblocks,\n\tprops = {},\n\t__experimentalLayout,\n} ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo( () => castArray( blocks ), [ blocks ] );\n\n\tconst children = (\n\t\t<BlockEditorProvider value={ renderedBlocks } settings={ settings }>\n\t\t\t<BlockListItems\n\t\t\t\trenderAppender={ false }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t/>\n\t\t</BlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { Disabled } from '@wordpress/components';
|
|
7
3
|
/**
|
|
8
4
|
* Internal dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import BlockList from '../block-list';
|
|
12
7
|
export default function LiveBlockPreview(_ref) {
|
|
13
8
|
let {
|
|
@@ -18,6 +13,8 @@ export default function LiveBlockPreview(_ref) {
|
|
|
18
13
|
role: "button",
|
|
19
14
|
onClick: onClick,
|
|
20
15
|
onKeyPress: onClick
|
|
21
|
-
}, createElement(
|
|
16
|
+
}, createElement("div", {
|
|
17
|
+
inert: "true"
|
|
18
|
+
}, createElement(BlockList, null)));
|
|
22
19
|
}
|
|
23
20
|
//# sourceMappingURL=live.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/live.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/live.js"],"names":["BlockList","LiveBlockPreview","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,eAAtB;AAEA,eAAe,SAASC,gBAAT,OAAyC;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACvD,SACC;AACC,IAAA,QAAQ,EAAG,CADZ;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,OAAO,EAAGA,OAHX;AAIC,IAAA,UAAU,EAAGA;AAJd,KAMC;AAAK,IAAA,KAAK,EAAC;AAAX,KACC,cAAC,SAAD,OADD,CAND,CADD;AAYA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\n\nexport default function LiveBlockPreview( { onClick } ) {\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tonClick={ onClick }\n\t\t\tonKeyPress={ onClick }\n\t\t>\n\t\t\t<div inert=\"true\">\n\t\t\t\t<BlockList />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -21,13 +21,21 @@ import { store as blockEditorStore } from '../../store';
|
|
|
21
21
|
|
|
22
22
|
export function useBlockSelectionClearer() {
|
|
23
23
|
const {
|
|
24
|
+
getSettings,
|
|
24
25
|
hasSelectedBlock,
|
|
25
26
|
hasMultiSelection
|
|
26
27
|
} = useSelect(blockEditorStore);
|
|
27
28
|
const {
|
|
28
29
|
clearSelectedBlock
|
|
29
30
|
} = useDispatch(blockEditorStore);
|
|
31
|
+
const {
|
|
32
|
+
__experimentalClearBlockSelection: isEnabled
|
|
33
|
+
} = getSettings();
|
|
30
34
|
return useRefEffect(node => {
|
|
35
|
+
if (!isEnabled) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
function onMouseDown(event) {
|
|
32
40
|
if (!hasSelectedBlock() && !hasMultiSelection()) {
|
|
33
41
|
return;
|
|
@@ -45,7 +53,7 @@ export function useBlockSelectionClearer() {
|
|
|
45
53
|
return () => {
|
|
46
54
|
node.removeEventListener('mousedown', onMouseDown);
|
|
47
55
|
};
|
|
48
|
-
}, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
|
|
56
|
+
}, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock, isEnabled]);
|
|
49
57
|
}
|
|
50
58
|
export default function BlockSelectionClearer(props) {
|
|
51
59
|
return createElement("div", _extends({
|