@wordpress/block-editor 15.11.1-next.v.0 → 15.12.1-next.v.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-breadcrumb/index.cjs +10 -2
- package/build/components/block-breadcrumb/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +11 -11
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-list/block.cjs +6 -3
- package/build/components/block-list/block.cjs.map +3 -3
- package/build/components/block-list/index.cjs +26 -18
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +2 -6
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-list/use-in-between-inserter.cjs +4 -4
- package/build/components/block-list/use-in-between-inserter.cjs.map +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.cjs +10 -7
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs +1 -1
- package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +10 -15
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +6 -4
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +1 -1
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +1 -2
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +5 -92
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/inserter/index.cjs +1 -0
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inspector-controls/last-item.cjs +41 -0
- package/build/components/inspector-controls/last-item.cjs.map +7 -0
- package/build/components/inspector-controls-tabs/index.cjs +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +4 -4
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/media-replace-flow/index.cjs +2 -2
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +1 -1
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +1 -1
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +2 -2
- package/build/components/writing-flow/use-arrow-nav.cjs +3 -0
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-drag-selection.cjs +2 -1
- package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-preview-mode-nav.cjs +92 -0
- package/build/components/writing-flow/use-preview-mode-nav.cjs.map +7 -0
- package/build/hooks/anchor.cjs +1 -1
- package/build/hooks/anchor.cjs.map +1 -1
- package/build/hooks/block-renaming.cjs +1 -1
- package/build/hooks/block-renaming.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +1 -1
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +42 -5
- package/build/hooks/grid-visualizer.cjs.map +3 -3
- package/build/hooks/index.cjs +0 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout-child.cjs +41 -5
- package/build/hooks/layout-child.cjs.map +3 -3
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +5 -0
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +1 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +5 -7
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +15 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +17 -7
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-breadcrumb/index.mjs +10 -2
- package/build-module/components/block-breadcrumb/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +12 -11
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +6 -3
- package/build-module/components/block-list/block.mjs.map +3 -3
- package/build-module/components/block-list/index.mjs +26 -18
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +2 -6
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-list/use-in-between-inserter.mjs +4 -4
- package/build-module/components/block-list/use-in-between-inserter.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +10 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs +1 -1
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +10 -15
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +6 -4
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +1 -1
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +1 -2
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +5 -92
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +1 -0
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inspector-controls/last-item.mjs +23 -0
- package/build-module/components/inspector-controls/last-item.mjs.map +7 -0
- package/build-module/components/inspector-controls-tabs/index.mjs +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +4 -4
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/media-replace-flow/index.mjs +2 -2
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -1
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +1 -1
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +3 -0
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-drag-selection.mjs +2 -1
- package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-preview-mode-nav.mjs +67 -0
- package/build-module/components/writing-flow/use-preview-mode-nav.mjs.map +7 -0
- package/build-module/hooks/anchor.mjs +1 -1
- package/build-module/hooks/anchor.mjs.map +1 -1
- package/build-module/hooks/block-renaming.mjs +1 -1
- package/build-module/hooks/block-renaming.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +1 -1
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +20 -5
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/index.mjs +0 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +31 -5
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +5 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +1 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +5 -7
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +15 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +17 -7
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/content-rtl.css +10 -0
- package/build-style/content.css +10 -0
- package/package.json +39 -39
- package/src/components/block-breadcrumb/index.js +6 -1
- package/src/components/block-inspector/index.js +20 -21
- package/src/components/block-list/block.js +5 -2
- package/src/components/block-list/content.scss +11 -0
- package/src/components/block-list/index.js +25 -17
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -7
- package/src/components/block-list/use-in-between-inserter.js +8 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +11 -6
- package/src/components/block-settings-menu-controls/edit-section-menu-item.js +1 -7
- package/src/components/block-settings-menu-controls/index.js +14 -16
- package/src/components/block-toolbar/block-toolbar-icon.js +6 -10
- package/src/components/block-toolbar/index.js +1 -7
- package/src/components/block-variation-transforms/index.js +1 -4
- package/src/components/inserter/index.js +1 -0
- package/src/components/inserter/stories/index.story.jsx +31 -24
- package/src/components/inspector-controls/last-item.js +29 -0
- package/src/components/inspector-controls-tabs/index.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +10 -11
- package/src/components/media-replace-flow/index.js +3 -3
- package/src/components/rich-text/index.js +1 -1
- package/src/components/use-block-display-information/index.js +1 -5
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +5 -0
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-preview-mode-nav.js +102 -0
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/block-renaming.js +5 -2
- package/src/hooks/custom-css.js +1 -1
- package/src/hooks/grid-visualizer.js +23 -4
- package/src/hooks/index.js +0 -2
- package/src/hooks/layout-child.js +39 -3
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +7 -0
- package/src/store/private-selectors.js +0 -1
- package/src/store/reducer.js +11 -18
- package/src/store/selectors.js +25 -0
- package/src/store/test/reducer.js +258 -266
- package/src/utils/fit-text-utils.js +24 -8
- package/build/components/content-lock/index.cjs +0 -31
- package/build/components/content-lock/index.cjs.map +0 -7
- package/build/components/content-lock/modify-content-lock-menu-item.cjs +0 -70
- package/build/components/content-lock/modify-content-lock-menu-item.cjs.map +0 -7
- package/build/hooks/content-lock-ui.cjs +0 -68
- package/build/hooks/content-lock-ui.cjs.map +0 -7
- package/build-module/components/content-lock/index.mjs +0 -6
- package/build-module/components/content-lock/index.mjs.map +0 -7
- package/build-module/components/content-lock/modify-content-lock-menu-item.mjs +0 -45
- package/build-module/components/content-lock/modify-content-lock-menu-item.mjs.map +0 -7
- package/build-module/hooks/content-lock-ui.mjs +0 -47
- package/build-module/hooks/content-lock-ui.mjs.map +0 -7
- package/src/components/content-lock/index.js +0 -1
- package/src/components/content-lock/modify-content-lock-menu-item.js +0 -67
- package/src/hooks/content-lock-ui.js +0 -76
|
@@ -35,6 +35,7 @@ function setContentEditableWrapper(node, value) {
|
|
|
35
35
|
function useDragSelection() {
|
|
36
36
|
const { startMultiSelect, stopMultiSelect } = (0, import_data.useDispatch)(import_store.store);
|
|
37
37
|
const {
|
|
38
|
+
getSettings,
|
|
38
39
|
isSelectionEnabled,
|
|
39
40
|
hasSelectedBlock,
|
|
40
41
|
isDraggingBlocks,
|
|
@@ -90,7 +91,7 @@ function useDragSelection() {
|
|
|
90
91
|
if (node === target) {
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
|
-
if (target.getAttribute("contenteditable") !== "true") {
|
|
94
|
+
if (target.getAttribute("contenteditable") !== "true" && !getSettings().isPreviewMode) {
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
if (!isSelectionEnabled()) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/writing-flow/use-drag-selection.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) {\n\t\tnode.focus();\n\t}\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tisSelectionEnabled,\n\t\thasSelectedBlock,\n\t\tisDraggingBlocks,\n\t\tisMultiSelecting,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tif ( ! hasSelectedBlock() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst { commonAncestorContainer } = range;\n\t\t\t\t\t\tconst clonedRange = range.cloneRange();\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t\t\tselection.addRange( clonedRange );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet lastMouseDownTarget;\n\n\t\t\tfunction onMouseDown( { target } ) {\n\t\t\t\tlastMouseDownTarget = target;\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target, relatedTarget } ) {\n\t\t\t\tif ( ! target.contains( lastMouseDownTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If we're moving into a child element, ignore. We're tracking\n\t\t\t\t// the mouse leaving the element to a parent, no a child.\n\t\t\t\tif ( target.contains( relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if we are already multi-selecting.\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if selection is leaving writing flow.\n\t\t\t\tif ( node === target ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the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/C;AAAA,QACD;AAIA,YAAK,OAAO,SAAU,aAAc,GAAI;AACvC;AAAA,QACD;AAIA,YAAK,iBAAiB,GAAI;AACzB;AAAA,QACD;AAIA,YAAK,YAAY,GAAI;AACpB;AAAA,QACD;AAGA,YAAK,iBAAiB,GAAI;AACzB;AAAA,QACD;AAGA,YAAK,SAAS,QAAS;AACtB;AAAA,QACD;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) {\n\t\tnode.focus();\n\t}\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetSettings,\n\t\tisSelectionEnabled,\n\t\thasSelectedBlock,\n\t\tisDraggingBlocks,\n\t\tisMultiSelecting,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tif ( ! hasSelectedBlock() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst { commonAncestorContainer } = range;\n\t\t\t\t\t\tconst clonedRange = range.cloneRange();\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t\t\tselection.addRange( clonedRange );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet lastMouseDownTarget;\n\n\t\t\tfunction onMouseDown( { target } ) {\n\t\t\t\tlastMouseDownTarget = target;\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target, relatedTarget } ) {\n\t\t\t\tif ( ! target.contains( lastMouseDownTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If we're moving into a child element, ignore. We're tracking\n\t\t\t\t// the mouse leaving the element to a parent, no a child.\n\t\t\t\tif ( target.contains( relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if we are already multi-selecting.\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if selection is leaving writing flow.\n\t\t\t\tif ( node === target ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\t// In preview mode, allow drag selection from blocks since they\n\t\t\t\t// are not contenteditable.\n\t\t\t\tif (\n\t\t\t\t\ttarget.getAttribute( 'contenteditable' ) !== 'true' &&\n\t\t\t\t\t! getSettings().isPreviewMode\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Do not rely on the active element because it may change after\n\t\t\t\t// the mouse leaves for the first time. See\n\t\t\t\t// https://github.com/WordPress/gutenberg/issues/48747.\n\t\t\t\tanchorElement = target;\n\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasSelectedBlock,\n\t\t]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAQ1C,SAAS,0BAA2B,MAAM,OAAQ;AACjD,OAAK,kBAAkB;AAEvB,MAAK,OAAQ;AACZ,SAAK,MAAM;AAAA,EACZ;AACD;AAKe,SAAR,mBAAoC;AAC1C,QAAM,EAAE,kBAAkB,gBAAgB,QACzC,yBAAa,aAAAA,KAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,aAAAA,KAAiB;AAChC,aAAO;AAAA,IACN,CAAE,SAAU;AACX,YAAM,EAAE,cAAc,IAAI;AAC1B,YAAM,EAAE,YAAY,IAAI;AAExB,UAAI;AACJ,UAAI;AAEJ,eAAS,YAAY;AACpB,wBAAgB;AAEhB,oBAAY,oBAAqB,WAAW,SAAU;AAItD,gBAAQ,YAAY,sBAAuB,MAAM;AAChD,cAAK,CAAE,iBAAiB,GAAI;AAC3B;AAAA,UACD;AAOA,oCAA2B,MAAM,KAAM;AAEvC,gBAAM,YAAY,YAAY,aAAa;AAE3C,cAAK,UAAU,YAAa;AAC3B,kBAAM,QAAQ,UAAU,WAAY,CAAE;AACtC,kBAAM,EAAE,wBAAwB,IAAI;AACpC,kBAAM,cAAc,MAAM,WAAW;AAErC,gBACC,cAAc,SAAU,uBAAwB,GAC/C;AACD,4BAAc,MAAM;AACpB,wBAAU,gBAAgB;AAC1B,wBAAU,SAAU,WAAY;AAAA,YACjC;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AAEA,UAAI;AAEJ,eAAS,YAAa,EAAE,OAAO,GAAI;AAClC,8BAAsB;AAAA,MACvB;AAEA,eAAS,aAAc,EAAE,SAAS,QAAQ,cAAc,GAAI;AAC3D,YAAK,CAAE,OAAO,SAAU,mBAAoB,GAAI;AAC/C;AAAA,QACD;AAIA,YAAK,OAAO,SAAU,aAAc,GAAI;AACvC;AAAA,QACD;AAIA,YAAK,iBAAiB,GAAI;AACzB;AAAA,QACD;AAIA,YAAK,YAAY,GAAI;AACpB;AAAA,QACD;AAGA,YAAK,iBAAiB,GAAI;AACzB;AAAA,QACD;AAGA,YAAK,SAAS,QAAS;AACtB;AAAA,QACD;AAQA,YACC,OAAO,aAAc,iBAAkB,MAAM,UAC7C,CAAE,YAAY,EAAE,eACf;AACD;AAAA,QACD;AAEA,YAAK,CAAE,mBAAmB,GAAI;AAC7B;AAAA,QACD;AAKA,wBAAgB;AAEhB,yBAAiB;AAKjB,oBAAY,iBAAkB,WAAW,SAAU;AAMnD,kCAA2B,MAAM,IAAK;AAAA,MACvC;AAEA,WAAK,iBAAkB,YAAY,YAAa;AAChD,WAAK,iBAAkB,aAAa,WAAY;AAEhD,aAAO,MAAM;AACZ,aAAK,oBAAqB,YAAY,YAAa;AACnD,oBAAY,oBAAqB,WAAW,SAAU;AACtD,oBAAY,qBAAsB,KAAM;AAAA,MACzC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/block-editor/src/components/writing-flow/use-preview-mode-nav.js
|
|
21
|
+
var use_preview_mode_nav_exports = {};
|
|
22
|
+
__export(use_preview_mode_nav_exports, {
|
|
23
|
+
usePreviewModeNav: () => usePreviewModeNav
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_preview_mode_nav_exports);
|
|
26
|
+
var import_compose = require("@wordpress/compose");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_keycodes = require("@wordpress/keycodes");
|
|
29
|
+
var import_store = require("../../store/index.cjs");
|
|
30
|
+
function usePreviewModeNav() {
|
|
31
|
+
const isPreviewMode = (0, import_data.useSelect)(
|
|
32
|
+
(select) => select(import_store.store).getSettings().isPreviewMode,
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
return (0, import_compose.useRefEffect)(
|
|
36
|
+
(node) => {
|
|
37
|
+
if (!isPreviewMode) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
function onKeyDown(event) {
|
|
41
|
+
const { keyCode, shiftKey, target } = event;
|
|
42
|
+
const isTab = keyCode === import_keycodes.TAB;
|
|
43
|
+
const isUp = keyCode === import_keycodes.UP;
|
|
44
|
+
const isDown = keyCode === import_keycodes.DOWN;
|
|
45
|
+
const isLeft = keyCode === import_keycodes.LEFT;
|
|
46
|
+
const isRight = keyCode === import_keycodes.RIGHT;
|
|
47
|
+
const isArrow = isUp || isDown || isLeft || isRight;
|
|
48
|
+
if (!isTab && !isArrow) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const isReverse = isTab ? shiftKey : isUp || isLeft;
|
|
52
|
+
const blocks = Array.from(
|
|
53
|
+
node.querySelectorAll("[data-block]")
|
|
54
|
+
);
|
|
55
|
+
if (!blocks.length) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const currentBlock = target.closest("[data-block]");
|
|
59
|
+
const currentIndex = currentBlock ? blocks.indexOf(currentBlock) : -1;
|
|
60
|
+
if (currentIndex === -1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (isTab) {
|
|
64
|
+
if (isReverse && currentIndex === 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!isReverse && currentIndex === blocks.length - 1) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let nextIndex;
|
|
72
|
+
if (isReverse) {
|
|
73
|
+
nextIndex = currentIndex <= 0 ? blocks.length - 1 : currentIndex - 1;
|
|
74
|
+
} else {
|
|
75
|
+
nextIndex = currentIndex === -1 || currentIndex >= blocks.length - 1 ? 0 : currentIndex + 1;
|
|
76
|
+
}
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
blocks[nextIndex].focus();
|
|
79
|
+
}
|
|
80
|
+
node.addEventListener("keydown", onKeyDown);
|
|
81
|
+
return () => {
|
|
82
|
+
node.removeEventListener("keydown", onKeyDown);
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
[isPreviewMode]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
usePreviewModeNav
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=use-preview-mode-nav.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/writing-flow/use-preview-mode-nav.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { TAB, UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * In preview mode, handles Tab and arrow key navigation to move only between\n * block elements, skipping all other focusable content.\n *\n * @return {Function} Ref callback.\n */\nexport function usePreviewModeNav() {\n\tconst isPreviewMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().isPreviewMode,\n\t\t[]\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tconst { keyCode, shiftKey, target } = event;\n\n\t\t\t\tconst isTab = keyCode === TAB;\n\t\t\t\tconst isUp = keyCode === UP;\n\t\t\t\tconst isDown = keyCode === DOWN;\n\t\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\t\tconst isArrow = isUp || isDown || isLeft || isRight;\n\n\t\t\t\tif ( ! isTab && ! isArrow ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isReverse = isTab ? shiftKey : isUp || isLeft;\n\n\t\t\t\tconst blocks = Array.from(\n\t\t\t\t\tnode.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tif ( ! blocks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst currentBlock = target.closest( '[data-block]' );\n\t\t\t\tconst currentIndex = currentBlock\n\t\t\t\t\t? blocks.indexOf( currentBlock )\n\t\t\t\t\t: -1;\n\n\t\t\t\t// If focus is not on a block, don't intercept navigation.\n\t\t\t\tif ( currentIndex === -1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// For Tab navigation, allow escaping the block list at boundaries.\n\t\t\t\t// For arrow keys, wrap around.\n\t\t\t\tif ( isTab ) {\n\t\t\t\t\tif ( isReverse && currentIndex === 0 ) {\n\t\t\t\t\t\t// At first block, Shift+Tab should exit the block list.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif ( ! isReverse && currentIndex === blocks.length - 1 ) {\n\t\t\t\t\t\t// At last block, Tab should exit the block list.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet nextIndex;\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tnextIndex =\n\t\t\t\t\t\tcurrentIndex <= 0\n\t\t\t\t\t\t\t? blocks.length - 1\n\t\t\t\t\t\t\t: currentIndex - 1;\n\t\t\t\t} else {\n\t\t\t\t\tnextIndex =\n\t\t\t\t\t\tcurrentIndex === -1 || currentIndex >= blocks.length - 1\n\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t: currentIndex + 1;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\t\t\t\tblocks[ nextIndex ].focus();\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t};\n\t\t},\n\t\t[ isPreviewMode ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,kBAA0B;AAC1B,sBAA2C;AAK3C,mBAA0C;AAQnC,SAAS,oBAAoB;AACnC,QAAM,oBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,aAAAA,KAAiB,EAAE,YAAY,EAAE;AAAA,IACvD,CAAC;AAAA,EACF;AAE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/anchor.cjs
CHANGED
|
@@ -62,7 +62,7 @@ function BlockEditAnchorControlPure({ anchor, setAttributes }) {
|
|
|
62
62
|
label: (0, import_i18n.__)("HTML anchor"),
|
|
63
63
|
help: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
64
64
|
(0, import_i18n.__)(
|
|
65
|
-
"Enter a word or two
|
|
65
|
+
"Enter a word or two\u2014without spaces\u2014to make a unique web address just for this block, called an \u201Canchor\u201D. Then, you\u2019ll be able to link directly to this section of your page."
|
|
66
66
|
),
|
|
67
67
|
isWeb && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
68
68
|
" ",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/anchor.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst isWeb = Platform.OS === 'web';\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Enter a word or two
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst isWeb = Platform.OS === 'web';\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Enter a word or two\u2014without spaces\u2014to make a unique web address just for this block, called an \u201Canchor\u201D. Then, you\u2019ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ ' ' }\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tvalue={ anchor || '' }\n\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tanchor: nextValue !== '' ? nextValue : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAC1B,wBAA0C;AAC1C,kBAAmB;AACnB,oBAAgC;AAChC,qBAAyB;AAKzB,IAAAA,qBAAkC;AAClC,gCAAoC;AAwD7B;AAjDP,IAAM,eAAe;AAUd,SAAS,aAAc,UAAW;AAExC,MAAK,WAAY,SAAS,YAAY,UAAU,CAAC,IAAM;AACtD,WAAO;AAAA,EACR;AACA,UAAK,+BAAiB,UAAU,QAAS,GAAI;AAE5C,aAAS,aAAa;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,QAAQ;AAAA,QACP,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,2BAA4B,EAAE,QAAQ,cAAc,GAAI;AAChE,QAAM,uBAAmB,+CAAoB;AAE7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,wBAAS,OAAO;AAE9B,SACC,4CAAC,wCAAkB,OAAM,YACxB;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,WAAU;AAAA,MACV,WAAQ,gBAAI,aAAc;AAAA,MAC1B,MACC,4EACG;AAAA;AAAA,UACD;AAAA,QACD;AAAA,QACE,SACD,4EACG;AAAA;AAAA,UACF;AAAA,YAAC;AAAA;AAAA,cACA,UAAO;AAAA,gBACN;AAAA,cACD;AAAA,cAEE,8BAAI,0BAA2B;AAAA;AAAA,UAClC;AAAA,WACD;AAAA,SAEF;AAAA,MAED,OAAQ,UAAU;AAAA,MAClB,aAAc,CAAE,YAAQ,gBAAI,eAAgB,IAAI;AAAA,MAChD,UAAW,CAAE,cAAe;AAC3B,oBAAY,UAAU,QAAS,cAAc,GAAI;AACjD,sBAAe;AAAA,UACd,QAAQ,cAAc,KAAK,YAAY;AAAA,QACxC,CAAE;AAAA,MACH;AAAA,MACA,gBAAe;AAAA,MACf,cAAa;AAAA;AAAA,EACd,GACD;AAEF;AAEA,IAAO,iBAAQ;AAAA,EACd;AAAA,EACA,MAAM;AAAA,EACN,eAAe,CAAE,QAAS;AAAA,EAC1B,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,QAAS;AAAA,EACxC;AACD;AAaO,SAAS,aAAc,YAAY,WAAW,YAAa;AACjE,UAAK,+BAAiB,WAAW,QAAS,GAAI;AAC7C,eAAW,KAAK,WAAW,WAAW,KAAK,OAAO,WAAW;AAAA,EAC9D;AAEA,SAAO;AACR;AAAA,IAEA,wBAAW,4BAA4B,yBAAyB,YAAa;",
|
|
6
6
|
"names": ["import_components"]
|
|
7
7
|
}
|
|
@@ -38,7 +38,7 @@ function addLabelCallback(settings) {
|
|
|
38
38
|
if (supportsBlockNaming) {
|
|
39
39
|
settings.__experimentalLabel = (attributes, { context }) => {
|
|
40
40
|
const { metadata } = attributes;
|
|
41
|
-
if (context === "list-view" && metadata?.name) {
|
|
41
|
+
if ((context === "list-view" || context === "breadcrumb") && metadata?.name) {
|
|
42
42
|
return metadata.name;
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/block-renaming.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view, use the block's name attribute as the label.\n\t\t\tif ( context === 'list-view'
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAC1B,oBAAgC;AASzB,SAAS,iBAAkB,UAAW;AAE5C,MAAK,SAAS,qBAAsB;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,0BAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EACD;AAGA,MAAK,qBAAsB;AAC1B,aAAS,sBAAsB,CAAE,YAAY,EAAE,QAAQ,MAAO;AAC7D,YAAM,EAAE,SAAS,IAAI;AAGrB,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view and breadcrumb, use the block's name attribute as the label.\n\t\t\tif (\n\t\t\t\t( context === 'list-view' || context === 'breadcrumb' ) &&\n\t\t\t\tmetadata?.name\n\t\t\t) {\n\t\t\t\treturn metadata.name;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addLabelCallback',\n\taddLabelCallback\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAC1B,oBAAgC;AASzB,SAAS,iBAAkB,UAAW;AAE5C,MAAK,SAAS,qBAAsB;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,0BAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EACD;AAGA,MAAK,qBAAsB;AAC1B,aAAS,sBAAsB,CAAE,YAAY,EAAE,QAAQ,MAAO;AAC7D,YAAM,EAAE,SAAS,IAAI;AAGrB,WACG,YAAY,eAAe,YAAY,iBACzC,UAAU,MACT;AACD,eAAO,SAAS;AAAA,MACjB;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/custom-css.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { processCSSNesting } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport AdvancedPanel, {\n\tvalidateCSS,\n} from '../components/global-styles/advanced-panel';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\n// Stable reference for useInstanceId.\nconst CUSTOM_CSS_INSTANCE_REFERENCE = {};\n\n// Stable empty object reference for useSelect.\nconst EMPTY_STYLE = {};\n\n/**\n * Inspector control for custom CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.blockName Block name.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {Object} props.style Block style attribute.\n */\nfunction CustomCSSControl( { blockName, setAttributes, style } ) {\n\tconst blockType = getBlockType( blockName );\n\n\tfunction onChange( newStyle ) {\n\t\t// Normalize whitespace-only CSS to undefined so it gets cleaned up.\n\t\tconst css = newStyle?.css?.trim() ? newStyle.css : undefined;\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( { ...newStyle, css } ),\n\t\t} );\n\t}\n\n\tconst cssHelpText = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.\n\t\t__(\n\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'\n\t\t),\n\t\tblockType?.title\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<AdvancedPanel\n\t\t\t\tvalue={ style }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tinheritedValue={ style }\n\t\t\t\thelp={ cssHelpText }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction CustomCSSEdit( { clientId, name, setAttributes } ) {\n\tconst { style, canEditCSS } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style || EMPTY_STYLE,\n\t\t\t\tcanEditCSS: getSettings().canEditCSS,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Don't render the panel if user lacks edit_css capability.\n\tif ( ! canEditCSS ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CustomCSSControl\n\t\t\tblockName={ name }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n/**\n * Hook to handle custom CSS for a block in the editor.\n * Generates a unique class and applies scoped CSS via style override.\n *\n * @param {Object} props Block props.\n * @param {Object} props.style Block style attribute.\n * @return {Object} Block props including className for custom CSS scoping.\n */\nfunction useBlockProps( { style } ) {\n\tconst customCSS = style?.css;\n\n\t// Validate CSS is non-empty and passes validation checks.\n\tconst isValidCSS =\n\t\ttypeof customCSS === 'string' &&\n\t\tcustomCSS.trim().length > 0 &&\n\t\tvalidateCSS( customCSS );\n\n\tconst customCSSIdentifier = useInstanceId(\n\t\tCUSTOM_CSS_INSTANCE_REFERENCE,\n\t\t'wp-custom-css'\n\t);\n\n\tconst customCSSSelector = `.${ customCSSIdentifier }`;\n\n\t// Transform the custom CSS using the same logic as global styles.\n\t// Only process if CSS is valid (doesn't contain HTML markup).\n\tconst transformedCSS = useMemo( () => {\n\t\tif ( ! isValidCSS ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn processCSSNesting( customCSS, customCSSSelector );\n\t}, [ customCSS, customCSSSelector, isValidCSS ] );\n\n\t// Inject the CSS via style override.\n\tuseStyleOverride( { css: transformedCSS } );\n\n\t// Only add the class if there's valid custom CSS.\n\tif ( ! isValidCSS ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tclassName: customCSSIdentifier
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAA0B;AAC1B,qBAA8B;AAC9B,oBAA8C;AAC9C,kBAA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AAE,SAAS,SAC1B,mCAAa,SAAU;AAExB,QAAM,0BAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,EACD;AAEA,QAAM,oBAAoB,IAAK,mBAAoB;AAInD,QAAM,qBAAiB,wBAAS,MAAM;AACrC,QAAK,CAAE,YAAa;AACnB,aAAO;AAAA,IACR;AACA,eAAO,+CAAmB,WAAW,iBAAkB;AAAA,EACxD,GAAG,CAAE,WAAW,mBAAmB,UAAW,CAAE;AAGhD,qCAAkB,EAAE,KAAK,eAAe,CAAE;AAG1C,MAAK,CAAE,YAAa;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { processCSSNesting } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport AdvancedPanel, {\n\tvalidateCSS,\n} from '../components/global-styles/advanced-panel';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\n// Stable reference for useInstanceId.\nconst CUSTOM_CSS_INSTANCE_REFERENCE = {};\n\n// Stable empty object reference for useSelect.\nconst EMPTY_STYLE = {};\n\n/**\n * Inspector control for custom CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.blockName Block name.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {Object} props.style Block style attribute.\n */\nfunction CustomCSSControl( { blockName, setAttributes, style } ) {\n\tconst blockType = getBlockType( blockName );\n\n\tfunction onChange( newStyle ) {\n\t\t// Normalize whitespace-only CSS to undefined so it gets cleaned up.\n\t\tconst css = newStyle?.css?.trim() ? newStyle.css : undefined;\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( { ...newStyle, css } ),\n\t\t} );\n\t}\n\n\tconst cssHelpText = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.\n\t\t__(\n\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'\n\t\t),\n\t\tblockType?.title\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<AdvancedPanel\n\t\t\t\tvalue={ style }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tinheritedValue={ style }\n\t\t\t\thelp={ cssHelpText }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction CustomCSSEdit( { clientId, name, setAttributes } ) {\n\tconst { style, canEditCSS } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style || EMPTY_STYLE,\n\t\t\t\tcanEditCSS: getSettings().canEditCSS,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Don't render the panel if user lacks edit_css capability.\n\tif ( ! canEditCSS ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CustomCSSControl\n\t\t\tblockName={ name }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n/**\n * Hook to handle custom CSS for a block in the editor.\n * Generates a unique class and applies scoped CSS via style override.\n *\n * @param {Object} props Block props.\n * @param {Object} props.style Block style attribute.\n * @return {Object} Block props including className for custom CSS scoping.\n */\nfunction useBlockProps( { style } ) {\n\tconst customCSS = style?.css;\n\n\t// Validate CSS is non-empty and passes validation checks.\n\tconst isValidCSS =\n\t\ttypeof customCSS === 'string' &&\n\t\tcustomCSS.trim().length > 0 &&\n\t\tvalidateCSS( customCSS );\n\n\tconst customCSSIdentifier = useInstanceId(\n\t\tCUSTOM_CSS_INSTANCE_REFERENCE,\n\t\t'wp-custom-css'\n\t);\n\n\tconst customCSSSelector = `.${ customCSSIdentifier }`;\n\n\t// Transform the custom CSS using the same logic as global styles.\n\t// Only process if CSS is valid (doesn't contain HTML markup).\n\tconst transformedCSS = useMemo( () => {\n\t\tif ( ! isValidCSS ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn processCSSNesting( customCSS, customCSSSelector );\n\t}, [ customCSS, customCSSSelector, isValidCSS ] );\n\n\t// Inject the CSS via style override.\n\tuseStyleOverride( { css: transformedCSS } );\n\n\t// Only add the class if there's valid custom CSS.\n\tif ( ! isValidCSS ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tclassName: `has-custom-css ${ customCSSIdentifier }`,\n\t};\n}\n\n/**\n * Adds a marker class to blocks with custom CSS for server-side rendering.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, 'customCSS', true ) ) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.style?.css?.trim() ) {\n\t\treturn props;\n\t}\n\n\t// Add a class to indicate this block has custom CSS.\n\t// The actual CSS is rendered server-side using the render_block filter.\n\tconst className = props.className\n\t\t? `${ props.className } has-custom-css`\n\t\t: 'has-custom-css';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\nexport default {\n\tedit: CustomCSSEdit,\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'customCSS', true );\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAA0B;AAC1B,qBAA8B;AAC9B,oBAA8C;AAC9C,kBAA4B;AAC5B,kCAAkC;AAKlC,gCAA8B;AAC9B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M,0BAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,EACD;AAEA,QAAM,oBAAoB,IAAK,mBAAoB;AAInD,QAAM,qBAAiB,wBAAS,MAAM;AACrC,QAAK,CAAE,YAAa;AACnB,aAAO;AAAA,IACR;AACA,eAAO,+CAAmB,WAAW,iBAAkB;AAAA,EACxD,GAAG,CAAE,WAAW,mBAAmB,UAAW,CAAE;AAGhD,qCAAkB,EAAE,KAAK,eAAe,CAAE;AAG1C,MAAK,CAAE,YAAa;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,SAAO;AAAA,IACN,WAAW,kBAAmB,mBAAoB;AAAA,EACnD;AACD;AAUA,SAAS,aAAc,OAAO,WAAW,YAAa;AACrD,MAAK,KAAE,+BAAiB,WAAW,aAAa,IAAK,GAAI;AACxD,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,YAAY,OAAO,KAAK,KAAK,GAAI;AACvC,WAAO;AAAA,EACR;AAIA,QAAM,YAAY,MAAM,YACrB,GAAI,MAAM,SAAU,oBACpB;AAEH,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,aAAa,IAAK;AAAA,EACjD;AACD;",
|
|
6
6
|
"names": ["InspectorControls", "AdvancedPanel", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
2
24
|
|
|
3
25
|
// packages/block-editor/src/hooks/grid-visualizer.js
|
|
4
26
|
var import_compose = require("@wordpress/compose");
|
|
@@ -6,29 +28,44 @@ var import_hooks = require("@wordpress/hooks");
|
|
|
6
28
|
var import_data = require("@wordpress/data");
|
|
7
29
|
var import_grid = require("../components/grid/index.cjs");
|
|
8
30
|
var import_store = require("../store/index.cjs");
|
|
31
|
+
var import_use_block_visibility = __toESM(require("../components/block-visibility/use-block-visibility.cjs"));
|
|
32
|
+
var import_private_keys = require("../store/private-keys.cjs");
|
|
33
|
+
var import_constants = require("../components/block-visibility/constants.cjs");
|
|
9
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
10
35
|
function GridLayoutSync(props) {
|
|
11
36
|
(0, import_grid.useGridLayoutSync)(props);
|
|
12
37
|
}
|
|
13
38
|
function GridTools({ clientId, layout }) {
|
|
14
|
-
const isVisible = (0, import_data.useSelect)(
|
|
39
|
+
const { isVisible, blockVisibility, deviceType } = (0, import_data.useSelect)(
|
|
15
40
|
(select) => {
|
|
16
41
|
const {
|
|
17
42
|
isBlockSelected,
|
|
18
43
|
isDraggingBlocks,
|
|
19
44
|
getTemplateLock,
|
|
20
|
-
getBlockEditingMode
|
|
45
|
+
getBlockEditingMode,
|
|
46
|
+
getBlockAttributes,
|
|
47
|
+
getSettings
|
|
21
48
|
} = select(import_store.store);
|
|
22
49
|
if (!isDraggingBlocks() && !isBlockSelected(clientId) || getTemplateLock(clientId) || getBlockEditingMode(clientId) !== "default") {
|
|
23
|
-
return false;
|
|
50
|
+
return { isVisible: false };
|
|
24
51
|
}
|
|
25
|
-
|
|
52
|
+
const attributes = getBlockAttributes(clientId);
|
|
53
|
+
const settings = getSettings();
|
|
54
|
+
return {
|
|
55
|
+
isVisible: true,
|
|
56
|
+
blockVisibility: attributes?.metadata?.blockVisibility,
|
|
57
|
+
deviceType: settings?.[import_private_keys.deviceTypeKey]?.toLowerCase() || import_constants.BLOCK_VISIBILITY_VIEWPORTS.desktop.value
|
|
58
|
+
};
|
|
26
59
|
},
|
|
27
60
|
[clientId]
|
|
28
61
|
);
|
|
62
|
+
const { isBlockCurrentlyHidden } = (0, import_use_block_visibility.default)({
|
|
63
|
+
blockVisibility,
|
|
64
|
+
deviceType
|
|
65
|
+
});
|
|
29
66
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
30
67
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GridLayoutSync, { clientId }),
|
|
31
|
-
isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_grid.GridVisualizer, { clientId, parentLayout: layout })
|
|
68
|
+
isVisible && !isBlockCurrentlyHidden && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_grid.GridVisualizer, { clientId, parentLayout: layout })
|
|
32
69
|
] });
|
|
33
70
|
}
|
|
34
71
|
var addGridVisualizerToBlockEdit = (0, import_compose.createHigherOrderComponent)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/grid-visualizer.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { GridVisualizer, useGridLayoutSync } from '../components/grid';\nimport { store as blockEditorStore } from '../store';\n\nfunction GridLayoutSync( props ) {\n\tuseGridLayoutSync( props );\n}\n\nfunction GridTools( { clientId, layout } ) {\n\tconst isVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockSelected,\n\t\t\t\tisDraggingBlocks,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// These calls are purposely ordered from least expensive to most expensive.\n\t\t\t// Hides the visualizer in cases where the user is not or cannot interact with it.\n\t\t\tif (\n\t\t\t\t( ! isDraggingBlocks() && ! isBlockSelected( clientId ) ) ||\n\t\t\t\tgetTemplateLock( clientId ) ||\n\t\t\t\tgetBlockEditingMode( clientId ) !== 'default'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<GridLayoutSync clientId={ clientId } />\n\t\t\t{ isVisible && (\n\t\t\t\t<GridVisualizer clientId={ clientId } parentLayout={ layout } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nconst addGridVisualizerToBlockEdit = createHigherOrderComponent(\n\t( BlockEdit ) =>\n\t\tfunction AddGridVisualizerToBlockEdit( props ) {\n\t\t\tif ( props.attributes.layout?.type !== 'grid' ) {\n\t\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<GridTools\n\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\tlayout={ props.attributes.layout }\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t'addGridVisualizerToBlockEdit'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/grid-visualizer',\n\taddGridVisualizerToBlockEdit\n);\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["blockEditorStore"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { GridVisualizer, useGridLayoutSync } from '../components/grid';\nimport { store as blockEditorStore } from '../store';\nimport useBlockVisibility from '../components/block-visibility/use-block-visibility';\nimport { deviceTypeKey } from '../store/private-keys';\nimport { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';\n\nfunction GridLayoutSync( props ) {\n\tuseGridLayoutSync( props );\n}\n\nfunction GridTools( { clientId, layout } ) {\n\tconst { isVisible, blockVisibility, deviceType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockSelected,\n\t\t\t\tisDraggingBlocks,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// These calls are purposely ordered from least expensive to most expensive.\n\t\t\t// Hides the visualizer in cases where the user is not or cannot interact with it.\n\t\t\tif (\n\t\t\t\t( ! isDraggingBlocks() && ! isBlockSelected( clientId ) ) ||\n\t\t\t\tgetTemplateLock( clientId ) ||\n\t\t\t\tgetBlockEditingMode( clientId ) !== 'default'\n\t\t\t) {\n\t\t\t\treturn { isVisible: false };\n\t\t\t}\n\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\tisVisible: true,\n\t\t\t\tblockVisibility: attributes?.metadata?.blockVisibility,\n\t\t\t\tdeviceType:\n\t\t\t\t\tsettings?.[ deviceTypeKey ]?.toLowerCase() ||\n\t\t\t\t\tBLOCK_VISIBILITY_VIEWPORTS.desktop.value,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { isBlockCurrentlyHidden } = useBlockVisibility( {\n\t\tblockVisibility,\n\t\tdeviceType,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<GridLayoutSync clientId={ clientId } />\n\t\t\t{ isVisible && ! isBlockCurrentlyHidden && (\n\t\t\t\t<GridVisualizer clientId={ clientId } parentLayout={ layout } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nconst addGridVisualizerToBlockEdit = createHigherOrderComponent(\n\t( BlockEdit ) =>\n\t\tfunction AddGridVisualizerToBlockEdit( props ) {\n\t\t\tif ( props.attributes.layout?.type !== 'grid' ) {\n\t\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<GridTools\n\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\tlayout={ props.attributes.layout }\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t'addGridVisualizerToBlockEdit'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/grid-visualizer',\n\taddGridVisualizerToBlockEdit\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,qBAA2C;AAC3C,mBAA0B;AAC1B,kBAA0B;AAK1B,kBAAkD;AAClD,mBAA0C;AAC1C,kCAA+B;AAC/B,0BAA8B;AAC9B,uBAA2C;AAgDzC;AA9CF,SAAS,eAAgB,OAAQ;AAChC,qCAAmB,KAAM;AAC1B;AAEA,SAAS,UAAW,EAAE,UA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
|
+
"names": ["blockEditorStore", "useBlockVisibility"]
|
|
7
7
|
}
|
package/build/hooks/index.cjs
CHANGED
|
@@ -75,7 +75,6 @@ var import_position = __toESM(require("./position.cjs"));
|
|
|
75
75
|
var import_block_style_variation = __toESM(require("./block-style-variation.cjs"));
|
|
76
76
|
var import_layout = __toESM(require("./layout.cjs"));
|
|
77
77
|
var import_layout_child = __toESM(require("./layout-child.cjs"));
|
|
78
|
-
var import_content_lock_ui = __toESM(require("./content-lock-ui.cjs"));
|
|
79
78
|
var import_metadata = require("./metadata.cjs");
|
|
80
79
|
var import_block_hooks = __toESM(require("./block-hooks.cjs"));
|
|
81
80
|
var import_block_bindings = __toESM(require("./block-bindings.cjs"));
|
|
@@ -108,7 +107,6 @@ var import_utils2 = require("./utils.cjs");
|
|
|
108
107
|
import_fit_text.default,
|
|
109
108
|
import_position.default,
|
|
110
109
|
import_layout.default,
|
|
111
|
-
import_content_lock_ui.default,
|
|
112
110
|
import_block_hooks.default,
|
|
113
111
|
import_block_bindings.default,
|
|
114
112
|
import_layout_child.default,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tcreateBlockEditFilter,\n\tcreateBlockListBlockFilter,\n\tcreateBlockSaveFilter,\n} from './utils';\nimport './compat';\nimport './cross-origin-isolation';\nimport align from './align';\nimport background from './background';\nimport './lock';\nimport allowedBlocks from './allowed-blocks';\nimport anchor from './anchor';\nimport ariaLabel from './aria-label';\nimport blockFields from './block-fields';\nimport customClassName from './custom-class-name';\nimport './generated-class-name';\nimport style from './style';\nimport './settings';\nimport color from './color';\nimport dimensions from './dimensions';\nimport duotone from './duotone';\nimport fontFamily from './font-family';\nimport fontSize from './font-size';\nimport textAlign from './text-align';\nimport fitText from './fit-text';\nimport border from './border';\nimport customCSS from './custom-css';\nimport position from './position';\nimport blockStyleVariation from './block-style-variation';\nimport layout from './layout';\nimport childLayout from './layout-child';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAIO;AACP,oBAAO;AACP,oCAAO;AACP,mBAAkB;AAClB,wBAAuB;AACvB,kBAAO;AACP,4BAA0B;AAC1B,oBAAmB;AACnB,wBAAsB;AACtB,0BAAwB;AACxB,+BAA4B;AAC5B,kCAAO;AACP,mBAAkB;AAClB,sBAAO;AACP,mBAAkB;AAClB,wBAAuB;AACvB,qBAAoB;AACpB,yBAAuB;AACvB,uBAAqB;AACrB,wBAAsB;AACtB,sBAAoB;AACpB,oBAAmB;AACnB,wBAAsB;AACtB,sBAAqB;AACrB,mCAAgC;AAChC,oBAAmB;AACnB,0BAAwB;AACxB,
|
|
6
|
-
"names": ["import_dimensions", "import_layout", "import_background", "import_block_style_variation", "import_utils", "align", "textAlign", "anchor", "customClassName", "style", "customCSS", "duotone", "fitText", "position", "layout", "
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tcreateBlockEditFilter,\n\tcreateBlockListBlockFilter,\n\tcreateBlockSaveFilter,\n} from './utils';\nimport './compat';\nimport './cross-origin-isolation';\nimport align from './align';\nimport background from './background';\nimport './lock';\nimport allowedBlocks from './allowed-blocks';\nimport anchor from './anchor';\nimport ariaLabel from './aria-label';\nimport blockFields from './block-fields';\nimport customClassName from './custom-class-name';\nimport './generated-class-name';\nimport style from './style';\nimport './settings';\nimport color from './color';\nimport dimensions from './dimensions';\nimport duotone from './duotone';\nimport fontFamily from './font-family';\nimport fontSize from './font-size';\nimport textAlign from './text-align';\nimport fitText from './fit-text';\nimport border from './border';\nimport customCSS from './custom-css';\nimport position from './position';\nimport blockStyleVariation from './block-style-variation';\nimport layout from './layout';\nimport childLayout from './layout-child';\nimport './metadata';\nimport blockHooks from './block-hooks';\nimport blockBindingsPanel from './block-bindings';\nimport listView from './list-view';\nimport './block-renaming';\nimport './grid-visualizer';\nimport autoInspectorControls from './auto-inspector-controls';\n\ncreateBlockEditFilter(\n\t[\n\t\talign,\n\t\ttextAlign,\n\t\tanchor,\n\t\tcustomClassName,\n\t\tstyle,\n\t\tcustomCSS,\n\t\tduotone,\n\t\tfitText,\n\t\tposition,\n\t\tlayout,\n\t\tblockHooks,\n\t\tblockBindingsPanel,\n\t\tchildLayout,\n\t\tallowedBlocks,\n\t\tblockFields,\n\t\tlistView,\n\t\tautoInspectorControls,\n\t].filter( Boolean )\n);\ncreateBlockListBlockFilter( [\n\talign,\n\ttextAlign,\n\tbackground,\n\tstyle,\n\tcolor,\n\tdimensions,\n\tduotone,\n\tfontFamily,\n\tfontSize,\n\tfitText,\n\tborder,\n\tcustomCSS,\n\tposition,\n\tblockStyleVariation,\n\tchildLayout,\n] );\ncreateBlockSaveFilter( [\n\talign,\n\ttextAlign,\n\tanchor,\n\tariaLabel,\n\tcustomClassName,\n\tborder,\n\tcustomCSS,\n\tfitText,\n\tcolor,\n\tstyle,\n\tfontFamily,\n\tfontSize,\n] );\n\nexport { useCustomSides } from './dimensions';\nexport { useLayoutClasses, useLayoutStyles } from './layout';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getShadowClassesAndStyles } from './use-shadow-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { getTypographyClassesAndStyles } from './use-typography-props';\nexport { getGapCSSValue } from './gap';\nexport { useCachedTruthy } from './use-cached-truthy';\nexport { setBackgroundStyleDefaults } from './background';\nexport { useZoomOut } from './use-zoom-out';\nexport { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';\nexport { useStyleOverride } from './utils';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;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4B;AAAA,EAC3B,aAAAhB;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAgB;AAAA,EACA,aAAAb;AAAA,EACA,aAAAc;AAAA,EACA,kBAAAC;AAAA,EACA,eAAAb;AAAA,EACA,mBAAAc;AAAA,EACA,iBAAAC;AAAA,EACA,gBAAAd;AAAA,EACA,cAAAe;AAAA,EACA,kBAAAjB;AAAA,EACA,gBAAAG;AAAA,EACA,6BAAAe;AAAA,EACA,oBAAAX;AACD,CAAE;AAAA,IACF,oCAAuB;AAAA,EACtB,aAAAZ;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAsB;AAAA,EACA,yBAAArB;AAAA,EACA,cAAAmB;AAAA,EACA,kBAAAjB;AAAA,EACA,gBAAAE;AAAA,EACA,aAAAW;AAAA,EACA,aAAAd;AAAA,EACA,mBAAAgB;AAAA,EACA,iBAAAC;AACD,CAAE;",
|
|
6
|
+
"names": ["import_dimensions", "import_layout", "import_background", "import_block_style_variation", "import_utils", "align", "textAlign", "anchor", "customClassName", "style", "customCSS", "duotone", "fitText", "position", "layout", "blockHooks", "blockBindingsPanel", "childLayout", "allowedBlocks", "blockFields", "listView", "autoInspectorControls", "background", "color", "dimensions", "fontFamily", "fontSize", "border", "blockStyleVariation", "ariaLabel"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// packages/block-editor/src/hooks/layout-child.js
|
|
@@ -30,6 +40,9 @@ var import_store = require("../store/index.cjs");
|
|
|
30
40
|
var import_utils = require("./utils.cjs");
|
|
31
41
|
var import_layout = require("../components/block-list/layout.cjs");
|
|
32
42
|
var import_grid = require("../components/grid/index.cjs");
|
|
43
|
+
var import_use_block_visibility = __toESM(require("../components/block-visibility/use-block-visibility.cjs"));
|
|
44
|
+
var import_private_keys = require("../store/private-keys.cjs");
|
|
45
|
+
var import_constants = require("../components/block-visibility/constants.cjs");
|
|
33
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
47
|
var LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};
|
|
35
48
|
function useBlockPropsChildLayoutStyles({ style }) {
|
|
@@ -171,12 +184,20 @@ function GridTools({
|
|
|
171
184
|
isManualPlacement,
|
|
172
185
|
parentLayout
|
|
173
186
|
}) {
|
|
174
|
-
const {
|
|
187
|
+
const {
|
|
188
|
+
rootClientId,
|
|
189
|
+
isVisible,
|
|
190
|
+
parentBlockVisibility,
|
|
191
|
+
blockBlockVisibility,
|
|
192
|
+
deviceType
|
|
193
|
+
} = (0, import_data.useSelect)(
|
|
175
194
|
(select) => {
|
|
176
195
|
const {
|
|
177
196
|
getBlockRootClientId,
|
|
178
197
|
getBlockEditingMode,
|
|
179
|
-
getTemplateLock
|
|
198
|
+
getTemplateLock,
|
|
199
|
+
getBlockAttributes,
|
|
200
|
+
getSettings
|
|
180
201
|
} = select(import_store.store);
|
|
181
202
|
const _rootClientId = getBlockRootClientId(clientId);
|
|
182
203
|
if (getTemplateLock(_rootClientId) || getBlockEditingMode(_rootClientId) !== "default") {
|
|
@@ -185,17 +206,32 @@ function GridTools({
|
|
|
185
206
|
isVisible: false
|
|
186
207
|
};
|
|
187
208
|
}
|
|
209
|
+
const parentAttributes = getBlockAttributes(_rootClientId);
|
|
210
|
+
const blockAttributes = getBlockAttributes(clientId);
|
|
211
|
+
const settings = getSettings();
|
|
188
212
|
return {
|
|
189
213
|
rootClientId: _rootClientId,
|
|
190
|
-
isVisible: true
|
|
214
|
+
isVisible: true,
|
|
215
|
+
parentBlockVisibility: parentAttributes?.metadata?.blockVisibility,
|
|
216
|
+
blockBlockVisibility: blockAttributes?.metadata?.blockVisibility,
|
|
217
|
+
deviceType: settings?.[import_private_keys.deviceTypeKey]?.toLowerCase() || import_constants.BLOCK_VISIBILITY_VIEWPORTS.desktop.value
|
|
191
218
|
};
|
|
192
219
|
},
|
|
193
220
|
[clientId]
|
|
194
221
|
);
|
|
222
|
+
const { isBlockCurrentlyHidden: isParentBlockCurrentlyHidden } = (0, import_use_block_visibility.default)({
|
|
223
|
+
blockVisibility: parentBlockVisibility,
|
|
224
|
+
deviceType
|
|
225
|
+
});
|
|
226
|
+
const { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } = (0, import_use_block_visibility.default)({
|
|
227
|
+
blockVisibility: blockBlockVisibility,
|
|
228
|
+
deviceType
|
|
229
|
+
});
|
|
195
230
|
const [resizerBounds, setResizerBounds] = (0, import_element.useState)();
|
|
196
|
-
if (!isVisible) {
|
|
231
|
+
if (!isVisible || isParentBlockCurrentlyHidden) {
|
|
197
232
|
return null;
|
|
198
233
|
}
|
|
234
|
+
const showResizer = allowSizingOnChildren && !isBlockItselfCurrentlyHidden;
|
|
199
235
|
function updateLayout(layout) {
|
|
200
236
|
setAttributes({
|
|
201
237
|
style: {
|
|
@@ -216,7 +252,7 @@ function GridTools({
|
|
|
216
252
|
parentLayout
|
|
217
253
|
}
|
|
218
254
|
),
|
|
219
|
-
|
|
255
|
+
showResizer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
220
256
|
import_grid.GridItemResizer,
|
|
221
257
|
{
|
|
222
258
|
clientId,
|