@wordpress/block-editor 14.3.0 → 14.3.2
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/README.md +2 -2
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -4
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +5 -2
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +10 -7
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/tool-selector/index.js +2 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +2 -2
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +20 -23
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/store/private-actions.js +25 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +22 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +21 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -4
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +5 -2
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +10 -7
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +2 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +2 -2
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +20 -23
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/store/private-actions.js +23 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +20 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +20 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -2
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +32 -32
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +7 -3
- package/src/components/block-tools/zoom-out-toolbar.js +5 -2
- package/src/components/block-variation-transforms/index.js +16 -6
- package/src/components/tool-selector/index.js +4 -1
- package/src/hooks/use-bindings-attributes.js +2 -3
- package/src/hooks/use-zoom-out.js +21 -27
- package/src/store/private-actions.js +23 -0
- package/src/store/private-selectors.js +20 -0
- package/src/store/reducer.js +20 -0
- package/src/store/selectors.js +7 -2
package/README.md
CHANGED
|
@@ -1027,11 +1027,11 @@ _Parameters_
|
|
|
1027
1027
|
|
|
1028
1028
|
### useZoomOut
|
|
1029
1029
|
|
|
1030
|
-
A hook used to set the
|
|
1030
|
+
A hook used to set the zoomed out view, invoking the hook sets the mode.
|
|
1031
1031
|
|
|
1032
1032
|
_Parameters_
|
|
1033
1033
|
|
|
1034
|
-
- _zoomOut_ `boolean`: If we should
|
|
1034
|
+
- _zoomOut_ `boolean`: If we should zoom out or not.
|
|
1035
1035
|
|
|
1036
1036
|
### Warning
|
|
1037
1037
|
|
|
@@ -25,13 +25,17 @@ function useZoomOutModeExit({
|
|
|
25
25
|
editorMode
|
|
26
26
|
}) {
|
|
27
27
|
const {
|
|
28
|
-
getSettings
|
|
29
|
-
|
|
28
|
+
getSettings,
|
|
29
|
+
isZoomOut
|
|
30
|
+
} = (0, _lockUnlock.unlock)((0, _data.useSelect)(_store.store));
|
|
30
31
|
const {
|
|
31
|
-
__unstableSetEditorMode
|
|
32
|
+
__unstableSetEditorMode,
|
|
33
|
+
resetZoomLevel
|
|
32
34
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
33
35
|
return (0, _compose.useRefEffect)(node => {
|
|
34
|
-
|
|
36
|
+
// In "compose" mode.
|
|
37
|
+
const composeMode = editorMode === 'zoom-out' && isZoomOut();
|
|
38
|
+
if (!composeMode) {
|
|
35
39
|
return;
|
|
36
40
|
}
|
|
37
41
|
function onDoubleClick(event) {
|
|
@@ -44,6 +48,7 @@ function useZoomOutModeExit({
|
|
|
44
48
|
__experimentalSetIsInserterOpened(false);
|
|
45
49
|
}
|
|
46
50
|
__unstableSetEditorMode('edit');
|
|
51
|
+
resetZoomLevel();
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
node.addEventListener('dblclick', onDoubleClick);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_compose","_store","_lockUnlock","useZoomOutModeExit","editorMode","getSettings","useSelect","blockEditorStore","__unstableSetEditorMode","
|
|
1
|
+
{"version":3,"names":["_data","require","_compose","_store","_lockUnlock","useZoomOutModeExit","editorMode","getSettings","isZoomOut","unlock","useSelect","blockEditorStore","__unstableSetEditorMode","resetZoomLevel","useDispatch","useRefEffect","node","composeMode","onDoubleClick","event","defaultPrevented","preventDefault","__experimentalSetIsInserterOpened","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js"],"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';\nimport { unlock } from '../../../lock-unlock';\n\n/**\n * Allows Zoom Out mode to be exited by double clicking in the selected block.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useZoomOutModeExit( { editorMode } ) {\n\tconst { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );\n\tconst { __unstableSetEditorMode, resetZoomLevel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\t// In \"compose\" mode.\n\t\t\tconst composeMode = editorMode === 'zoom-out' && isZoomOut();\n\n\t\t\tif ( ! composeMode ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onDoubleClick( event ) {\n\t\t\t\tif ( ! event.defaultPrevented ) {\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\tconst { __experimentalSetIsInserterOpened } = getSettings();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof __experimentalSetIsInserterOpened === 'function'\n\t\t\t\t\t) {\n\t\t\t\t\t\t__experimentalSetIsInserterOpened( false );\n\t\t\t\t\t}\n\t\t\t\t\t__unstableSetEditorMode( 'edit' );\n\t\t\t\t\tresetZoomLevel();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'dblclick', onDoubleClick );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'dblclick', onDoubleClick );\n\t\t\t};\n\t\t},\n\t\t[ editorMode, getSettings, __unstableSetEditorMode ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAAE;EAAEC;AAAW,CAAC,EAAG;EACpD,MAAM;IAAEC,WAAW;IAAEC;EAAU,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,eAAS,EAAEC,YAAiB,CAAE,CAAC;EAC1E,MAAM;IAAEC,uBAAuB;IAAEC;EAAe,CAAC,GAAG,IAAAJ,kBAAM,EACzD,IAAAK,iBAAW,EAAEH,YAAiB,CAC/B,CAAC;EAED,OAAO,IAAAI,qBAAY,EAChBC,IAAI,IAAM;IACX;IACA,MAAMC,WAAW,GAAGX,UAAU,KAAK,UAAU,IAAIE,SAAS,CAAC,CAAC;IAE5D,IAAK,CAAES,WAAW,EAAG;MACpB;IACD;IAEA,SAASC,aAAaA,CAAEC,KAAK,EAAG;MAC/B,IAAK,CAAEA,KAAK,CAACC,gBAAgB,EAAG;QAC/BD,KAAK,CAACE,cAAc,CAAC,CAAC;QAEtB,MAAM;UAAEC;QAAkC,CAAC,GAAGf,WAAW,CAAC,CAAC;QAE3D,IACC,OAAOe,iCAAiC,KAAK,UAAU,EACtD;UACDA,iCAAiC,CAAE,KAAM,CAAC;QAC3C;QACAV,uBAAuB,CAAE,MAAO,CAAC;QACjCC,cAAc,CAAC,CAAC;MACjB;IACD;IAEAG,IAAI,CAACO,gBAAgB,CAAE,UAAU,EAAEL,aAAc,CAAC;IAElD,OAAO,MAAM;MACZF,IAAI,CAACQ,mBAAmB,CAAE,UAAU,EAAEN,aAAc,CAAC;IACtD,CAAC;EACF,CAAC,EACD,CAAEZ,UAAU,EAAEC,WAAW,EAAEK,uBAAuB,CACnD,CAAC;AACF","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@ var _blockDraggable = _interopRequireDefault(require("../block-draggable"));
|
|
|
16
16
|
var _blockMover = _interopRequireDefault(require("../block-mover"));
|
|
17
17
|
var _shuffle = _interopRequireDefault(require("../block-toolbar/shuffle"));
|
|
18
18
|
var _navigableToolbar = _interopRequireDefault(require("../navigable-toolbar"));
|
|
19
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
/**
|
|
21
22
|
* External dependencies
|
|
@@ -93,8 +94,9 @@ function ZoomOutToolbar({
|
|
|
93
94
|
} = selected;
|
|
94
95
|
const {
|
|
95
96
|
removeBlock,
|
|
96
|
-
__unstableSetEditorMode
|
|
97
|
-
|
|
97
|
+
__unstableSetEditorMode,
|
|
98
|
+
resetZoomLevel
|
|
99
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
98
100
|
const classNames = (0, _clsx.default)('zoom-out-toolbar', {
|
|
99
101
|
'is-block-moving-mode': !!blockMovingMode
|
|
100
102
|
});
|
|
@@ -141,6 +143,7 @@ function ZoomOutToolbar({
|
|
|
141
143
|
setIsInserterOpened(false);
|
|
142
144
|
}
|
|
143
145
|
__unstableSetEditorMode('edit');
|
|
146
|
+
resetZoomLevel();
|
|
144
147
|
__unstableContentRef.current?.focus();
|
|
145
148
|
}
|
|
146
149
|
}), canRemove && !isBlockTemplatePart && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_components","_data","_blocks","_i18n","_store","_blockDraggable","_blockMover","_shuffle","_navigableToolbar","_jsxRuntime","ZoomOutToolbar","clientId","__unstableContentRef","selected","useSelect","select","getBlock","hasBlockMovingClientId","getNextBlockClientId","getPreviousBlockClientId","canRemoveBlock","canMoveBlock","getSettings","blockEditorStore","__experimentalSetIsInserterOpened","setIsInserterOpened","getBlockType","blocksStore","name","blockType","isBlockTemplatePart","isNextBlockTemplatePart","nextClientId","nextName","nextBlockType","isPrevBlockTemplatePart","prevClientId","prevName","prevBlockType","blockMovingMode","canRemove","canMove","removeBlock","__unstableSetEditorMode","useDispatch","classNames","clsx","showBlockDraggable","jsxs","default","className","__","variant","orientation","children","jsx","clientIds","draggableProps","Button","icon","dragHandle","label","iconSize","size","tabIndex","hideDragHandle","isBlockMoverUpButtonDisabled","isBlockMoverDownButtonDisabled","as","ToolbarButton","edit","onClick","current","focus","trash"],"sources":["@wordpress/block-editor/src/components/block-tools/zoom-out-toolbar.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { dragHandle, trash, edit } from '@wordpress/icons';\nimport { Button, ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockDraggable from '../block-draggable';\nimport BlockMover from '../block-mover';\nimport Shuffle from '../block-toolbar/shuffle';\nimport NavigableToolbar from '../navigable-toolbar';\n\nexport default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock,\n\t\t\t\thasBlockMovingClientId,\n\t\t\t\tgetNextBlockClientId,\n\t\t\t\tgetPreviousBlockClientId,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tcanMoveBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { __experimentalSetIsInserterOpened: setIsInserterOpened } =\n\t\t\t\tgetSettings();\n\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst { name } = getBlock( clientId );\n\t\t\tconst blockType = getBlockType( name );\n\t\t\tconst isBlockTemplatePart =\n\t\t\t\tblockType?.name === 'core/template-part';\n\n\t\t\tlet isNextBlockTemplatePart = false;\n\t\t\tconst nextClientId = getNextBlockClientId();\n\t\t\tif ( nextClientId ) {\n\t\t\t\tconst { name: nextName } = getBlock( nextClientId );\n\t\t\t\tconst nextBlockType = getBlockType( nextName );\n\t\t\t\tisNextBlockTemplatePart =\n\t\t\t\t\tnextBlockType?.name === 'core/template-part';\n\t\t\t}\n\n\t\t\tlet isPrevBlockTemplatePart = false;\n\t\t\tconst prevClientId = getPreviousBlockClientId();\n\t\t\tif ( prevClientId ) {\n\t\t\t\tconst { name: prevName } = getBlock( prevClientId );\n\t\t\t\tconst prevBlockType = getBlockType( prevName );\n\t\t\t\tisPrevBlockTemplatePart =\n\t\t\t\t\tprevBlockType?.name === 'core/template-part';\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tblockMovingMode: hasBlockMovingClientId(),\n\t\t\t\tisBlockTemplatePart,\n\t\t\t\tisNextBlockTemplatePart,\n\t\t\t\tisPrevBlockTemplatePart,\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tcanMove: canMoveBlock( clientId ),\n\t\t\t\tsetIsInserterOpened,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst {\n\t\tblockMovingMode,\n\t\tisBlockTemplatePart,\n\t\tisNextBlockTemplatePart,\n\t\tisPrevBlockTemplatePart,\n\t\tcanRemove,\n\t\tcanMove,\n\t\tsetIsInserterOpened,\n\t} = selected;\n\n\tconst { removeBlock, __unstableSetEditorMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst classNames = clsx( 'zoom-out-toolbar', {\n\t\t'is-block-moving-mode': !! blockMovingMode,\n\t} );\n\n\tconst showBlockDraggable = canMove && ! isBlockTemplatePart;\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName={ classNames }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant=\"unstyled\"\n\t\t\torientation=\"vertical\"\n\t\t>\n\t\t\t{ showBlockDraggable && (\n\t\t\t\t<BlockDraggable clientIds={ [ clientId ] }>\n\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\tclassName=\"block-selection-button_drag-handle zoom-out-toolbar-button\"\n\t\t\t\t\t\t\tlabel={ __( 'Drag' ) }\n\t\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockDraggable>\n\t\t\t) }\n\t\t\t{ ! isBlockTemplatePart && (\n\t\t\t\t<BlockMover\n\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\thideDragHandle\n\t\t\t\t\tisBlockMoverUpButtonDisabled={ isPrevBlockTemplatePart }\n\t\t\t\t\tisBlockMoverDownButtonDisabled={ isNextBlockTemplatePart }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canMove && canRemove && (\n\t\t\t\t<Shuffle clientId={ clientId } as={ ToolbarButton } />\n\t\t\t) }\n\n\t\t\t{ ! isBlockTemplatePart && (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"zoom-out-toolbar-button\"\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t// Setting may be undefined.\n\t\t\t\t\t\tif ( typeof setIsInserterOpened === 'function' ) {\n\t\t\t\t\t\t\tsetIsInserterOpened( false );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__unstableSetEditorMode( 'edit' );\n\t\t\t\t\t\t__unstableContentRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ canRemove && ! isBlockTemplatePart && (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"zoom-out-toolbar-button\"\n\t\t\t\t\ticon={ trash }\n\t\t\t\t\tlabel={ __( 'Delete' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAA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qE,aAAa;MACbnB,SAAS,EAAC,yBAAyB;MACnCS,IAAI,EAAGe,YAAO;MACdb,KAAK,EAAG,IAAAV,QAAE,EAAE,QAAS,CAAG;MACxBoB,OAAO,EAAGA,CAAA,KAAM;QACf7B,WAAW,CAAE/B,QAAS,CAAC;MACxB;IAAG,CACH,CACD;EAAA,CACgB,CAAC;AAErB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_components","_data","_blocks","_i18n","_store","_blockDraggable","_blockMover","_shuffle","_navigableToolbar","_lockUnlock","_jsxRuntime","ZoomOutToolbar","clientId","__unstableContentRef","selected","useSelect","select","getBlock","hasBlockMovingClientId","getNextBlockClientId","getPreviousBlockClientId","canRemoveBlock","canMoveBlock","getSettings","blockEditorStore","__experimentalSetIsInserterOpened","setIsInserterOpened","getBlockType","blocksStore","name","blockType","isBlockTemplatePart","isNextBlockTemplatePart","nextClientId","nextName","nextBlockType","isPrevBlockTemplatePart","prevClientId","prevName","prevBlockType","blockMovingMode","canRemove","canMove","removeBlock","__unstableSetEditorMode","resetZoomLevel","unlock","useDispatch","classNames","clsx","showBlockDraggable","jsxs","default","className","__","variant","orientation","children","jsx","clientIds","draggableProps","Button","icon","dragHandle","label","iconSize","size","tabIndex","hideDragHandle","isBlockMoverUpButtonDisabled","isBlockMoverDownButtonDisabled","as","ToolbarButton","edit","onClick","current","focus","trash"],"sources":["@wordpress/block-editor/src/components/block-tools/zoom-out-toolbar.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { dragHandle, trash, edit } from '@wordpress/icons';\nimport { Button, ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockDraggable from '../block-draggable';\nimport BlockMover from '../block-mover';\nimport Shuffle from '../block-toolbar/shuffle';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { unlock } from '../../lock-unlock';\n\nexport default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock,\n\t\t\t\thasBlockMovingClientId,\n\t\t\t\tgetNextBlockClientId,\n\t\t\t\tgetPreviousBlockClientId,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tcanMoveBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { __experimentalSetIsInserterOpened: setIsInserterOpened } =\n\t\t\t\tgetSettings();\n\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst { name } = getBlock( clientId );\n\t\t\tconst blockType = getBlockType( name );\n\t\t\tconst isBlockTemplatePart =\n\t\t\t\tblockType?.name === 'core/template-part';\n\n\t\t\tlet isNextBlockTemplatePart = false;\n\t\t\tconst nextClientId = getNextBlockClientId();\n\t\t\tif ( nextClientId ) {\n\t\t\t\tconst { name: nextName } = getBlock( nextClientId );\n\t\t\t\tconst nextBlockType = getBlockType( nextName );\n\t\t\t\tisNextBlockTemplatePart =\n\t\t\t\t\tnextBlockType?.name === 'core/template-part';\n\t\t\t}\n\n\t\t\tlet isPrevBlockTemplatePart = false;\n\t\t\tconst prevClientId = getPreviousBlockClientId();\n\t\t\tif ( prevClientId ) {\n\t\t\t\tconst { name: prevName } = getBlock( prevClientId );\n\t\t\t\tconst prevBlockType = getBlockType( prevName );\n\t\t\t\tisPrevBlockTemplatePart =\n\t\t\t\t\tprevBlockType?.name === 'core/template-part';\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tblockMovingMode: hasBlockMovingClientId(),\n\t\t\t\tisBlockTemplatePart,\n\t\t\t\tisNextBlockTemplatePart,\n\t\t\t\tisPrevBlockTemplatePart,\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tcanMove: canMoveBlock( clientId ),\n\t\t\t\tsetIsInserterOpened,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst {\n\t\tblockMovingMode,\n\t\tisBlockTemplatePart,\n\t\tisNextBlockTemplatePart,\n\t\tisPrevBlockTemplatePart,\n\t\tcanRemove,\n\t\tcanMove,\n\t\tsetIsInserterOpened,\n\t} = selected;\n\n\tconst { removeBlock, __unstableSetEditorMode, resetZoomLevel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst classNames = clsx( 'zoom-out-toolbar', {\n\t\t'is-block-moving-mode': !! blockMovingMode,\n\t} );\n\n\tconst showBlockDraggable = canMove && ! isBlockTemplatePart;\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName={ classNames }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant=\"unstyled\"\n\t\t\torientation=\"vertical\"\n\t\t>\n\t\t\t{ showBlockDraggable && (\n\t\t\t\t<BlockDraggable clientIds={ [ clientId ] }>\n\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\tclassName=\"block-selection-button_drag-handle zoom-out-toolbar-button\"\n\t\t\t\t\t\t\tlabel={ __( 'Drag' ) }\n\t\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockDraggable>\n\t\t\t) }\n\t\t\t{ ! isBlockTemplatePart && (\n\t\t\t\t<BlockMover\n\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\thideDragHandle\n\t\t\t\t\tisBlockMoverUpButtonDisabled={ isPrevBlockTemplatePart }\n\t\t\t\t\tisBlockMoverDownButtonDisabled={ isNextBlockTemplatePart }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canMove && canRemove && (\n\t\t\t\t<Shuffle clientId={ clientId } as={ ToolbarButton } />\n\t\t\t) }\n\n\t\t\t{ ! isBlockTemplatePart && (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"zoom-out-toolbar-button\"\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t// Setting may be undefined.\n\t\t\t\t\t\tif ( typeof setIsInserterOpened === 'function' ) {\n\t\t\t\t\t\t\tsetIsInserterOpened( false );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__unstableSetEditorMode( 'edit' );\n\t\t\t\t\t\tresetZoomLevel();\n\t\t\t\t\t\t__unstableContentRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ canRemove && ! isBlockTemplatePart && (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"zoom-out-toolbar-button\"\n\t\t\t\t\ticon={ trash }\n\t\t\t\t\tlabel={ __( 'Delete' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,G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AAoB,CAAC8D,OAAO,EAAEC,KAAK,CAAC,CAAC;MACtC;IAAG,CACH,CACD,EAECnC,SAAS,IAAI,CAAEV,mBAAmB,iBACnC,IAAArB,WAAA,CAAAgD,GAAA,EAAC1D,WAAA,CAAAwE,aAAa;MACbnB,SAAS,EAAC,yBAAyB;MACnCS,IAAI,EAAGe,YAAO;MACdb,KAAK,EAAG,IAAAV,QAAE,EAAE,QAAS,CAAG;MACxBoB,OAAO,EAAGA,CAAA,KAAM;QACf/B,WAAW,CAAE/B,QAAS,CAAC;MACxB;IAAG,CACH,CACD;EAAA,CACgB,CAAC;AAErB","ignoreList":[]}
|
|
@@ -124,20 +124,25 @@ function __experimentalBlockVariationTransforms({
|
|
|
124
124
|
} = (0, _data.useDispatch)(_store.store);
|
|
125
125
|
const {
|
|
126
126
|
activeBlockVariation,
|
|
127
|
-
variations
|
|
127
|
+
variations,
|
|
128
|
+
isContentOnly
|
|
128
129
|
} = (0, _data.useSelect)(select => {
|
|
129
130
|
const {
|
|
130
131
|
getActiveBlockVariation,
|
|
131
|
-
getBlockVariations
|
|
132
|
+
getBlockVariations,
|
|
133
|
+
__experimentalHasContentRoleAttribute
|
|
132
134
|
} = select(_blocks.store);
|
|
133
135
|
const {
|
|
134
136
|
getBlockName,
|
|
135
|
-
getBlockAttributes
|
|
137
|
+
getBlockAttributes,
|
|
138
|
+
getBlockEditingMode
|
|
136
139
|
} = select(_store.store);
|
|
137
140
|
const name = blockClientId && getBlockName(blockClientId);
|
|
141
|
+
const isContentBlock = __experimentalHasContentRoleAttribute(name);
|
|
138
142
|
return {
|
|
139
143
|
activeBlockVariation: getActiveBlockVariation(name, getBlockAttributes(blockClientId)),
|
|
140
|
-
variations: name && getBlockVariations(name, 'transform')
|
|
144
|
+
variations: name && getBlockVariations(name, 'transform'),
|
|
145
|
+
isContentOnly: getBlockEditingMode(blockClientId) === 'contentOnly' && !isContentBlock
|
|
141
146
|
};
|
|
142
147
|
}, [blockClientId]);
|
|
143
148
|
const selectedValue = activeBlockVariation?.name;
|
|
@@ -162,9 +167,7 @@ function __experimentalBlockVariationTransforms({
|
|
|
162
167
|
}) => name === variationName).attributes
|
|
163
168
|
});
|
|
164
169
|
};
|
|
165
|
-
|
|
166
|
-
// Skip rendering if there are no variations
|
|
167
|
-
if (!variations?.length) {
|
|
170
|
+
if (!variations?.length || isContentOnly) {
|
|
168
171
|
return null;
|
|
169
172
|
}
|
|
170
173
|
const baseClass = 'block-editor-block-variation-transforms';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_i18n","_components","_data","_element","_icons","_blockIcon","_interopRequireDefault","_store","_jsxRuntime","VariationsButtons","className","onSelectVariation","selectedValue","variations","jsxs","children","jsx","VisuallyHidden","as","__","map","variation","Button","__next40pxDefaultSize","icon","default","showColors","isPressed","name","label","title","sprintf","onClick","showTooltip","VariationsDropdown","selectOptions","description","value","info","DropdownMenu","text","popoverProps","position","chevronDown","toggleProps","iconPosition","MenuGroup","MenuItemsChoice","choices","onSelect","VariationsToggleGroupControl","__experimentalToggleGroupControl","hideLabelFromVision","onChange","__nextHasNoMarginBottom","__experimentalToggleGroupControlOptionIcon","__experimentalBlockVariationTransforms","blockClientId","updateBlockAttributes","useDispatch","blockEditorStore","activeBlockVariation","useSelect","select","getActiveBlockVariation","getBlockVariations","blocksStore","getBlockName","getBlockAttributes","hasUniqueIcons","useMemo","variationIcons","Set","forEach","add","src","size","length","variationName","find","attributes","baseClass","showButtons","ButtonComponent","Component","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-variation-transforms/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\n\nfunction VariationsButtons( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<fieldset className={ className }>\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\ticon={ <BlockIcon icon={ variation.icon } showColors /> }\n\t\t\t\t\tisPressed={ selectedValue === variation.name }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the block variation */\n\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\tvariation.title\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => onSelectVariation( variation.name ) }\n\t\t\t\t\taria-label={ variation.title }\n\t\t\t\t\tshowTooltip\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</fieldset>\n\t);\n}\n\nfunction VariationsDropdown( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\tconst selectOptions = variations.map(\n\t\t( { name, title, description } ) => ( {\n\t\t\tvalue: name,\n\t\t\tlabel: title,\n\t\t\tinfo: description,\n\t\t} )\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName={ className }\n\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\ttext={ __( 'Transform to variation' ) }\n\t\t\tpopoverProps={ {\n\t\t\t\tposition: 'bottom center',\n\t\t\t\tclassName: `${ className }__popover`,\n\t\t\t} }\n\t\t\ticon={ chevronDown }\n\t\t\ttoggleProps={ { iconPosition: 'right' } }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<div className={ `${ className }__container` }>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tchoices={ selectOptions }\n\t\t\t\t\t\t\tvalue={ selectedValue }\n\t\t\t\t\t\t\tonSelect={ onSelectVariation }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction VariationsToggleGroupControl( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\t\tvalue={ selectedValue }\n\t\t\t\thideLabelFromVision\n\t\t\t\tonChange={ onSelectVariation }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t>\n\t\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<BlockIcon icon={ variation.icon } showColors />\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ variation.name }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the block variation */\n\t\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\t\tvariation.title\n\t\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</ToggleGroupControl>\n\t\t</div>\n\t);\n}\n\nfunction __experimentalBlockVariationTransforms( { blockClientId } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { activeBlockVariation, variations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst name = blockClientId && getBlockName( blockClientId );\n\t\t\treturn {\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tgetBlockAttributes( blockClientId )\n\t\t\t\t),\n\t\t\t\tvariations: name && getBlockVariations( name, 'transform' ),\n\t\t\t};\n\t\t},\n\t\t[ blockClientId ]\n\t);\n\n\tconst selectedValue = activeBlockVariation?.name;\n\n\t// Check if each variation has a unique icon.\n\tconst hasUniqueIcons = useMemo( () => {\n\t\tconst variationIcons = new Set();\n\t\tif ( ! variations ) {\n\t\t\treturn false;\n\t\t}\n\t\tvariations.forEach( ( variation ) => {\n\t\t\tif ( variation.icon ) {\n\t\t\t\tvariationIcons.add( variation.icon?.src || variation.icon );\n\t\t\t}\n\t\t} );\n\t\treturn variationIcons.size === variations.length;\n\t}, [ variations ] );\n\n\tconst onSelectVariation = ( variationName ) => {\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\t...variations.find( ( { name } ) => name === variationName )\n\t\t\t\t.attributes,\n\t\t} );\n\t};\n\n\t// Skip rendering if there are no variations\n\tif ( ! variations?.length ) {\n\t\treturn null;\n\t}\n\n\tconst baseClass = 'block-editor-block-variation-transforms';\n\n\t// Show buttons if there are more than 5 variations because the ToggleGroupControl does not wrap\n\tconst showButtons = variations.length > 5;\n\n\tconst ButtonComponent = showButtons\n\t\t? VariationsButtons\n\t\t: VariationsToggleGroupControl;\n\n\tconst Component = hasUniqueIcons ? ButtonComponent : VariationsDropdown;\n\n\treturn (\n\t\t<Component\n\t\t\tclassName={ baseClass }\n\t\t\tonSelectVariation={ onSelectVariation }\n\t\t\tselectedValue={ selectedValue }\n\t\t\tvariations={ variations }\n\t\t/>\n\t);\n}\n\nexport default __experimentalBlockVariationTransforms;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAAwD,IAAAS,WAAA,GAAAT,OAAA;AAtBxD;AACA;AACA;;AAgBA;AACA;AACA;;AAIA,SAASU,iBAAiBA,CAAE;EAC3BC,SAAS;EACTC,iBAAiB;EACjBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,oBACC,IAAAL,WAAA,CAAAM,IAAA;IAAUJ,SAAS,EAAGA,SAAW;IAAAK,QAAA,gBAChC,IAAAP,WAAA,CAAAQ,GAAA,EAACf,WAAA,CAAAgB,cAAc;MAACC,EAAE,EAAC,QAAQ;MAAAH,QAAA,EACxB,IAAAI,QAAE,EAAE,wBAAyB;IAAC,CACjB,CAAC,EACfN,UAAU,CAACO,GAAG,CAAIC,SAAS,iBAC5B,IAAAb,WAAA,CAAAQ,GAAA,EAACf,WAAA,CAAAqB;IACA;IAAA;MACAC,qBAAqB,EAAG,KAAO;MAE/BC,IAAI,eAAG,IAAAhB,WAAA,CAAAQ,GAAA,EAACX,UAAA,CAAAoB,OAAS;QAACD,IAAI,EAAGH,SAAS,CAACG,IAAM;QAACE,UAAU;MAAA,CAAE,CAAG;MACzDC,SAAS,EAAGf,aAAa,KAAKS,SAAS,CAACO,IAAM;MAC9CC,KAAK,EACJjB,aAAa,KAA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1DE;IACH,CAAE,CAAC;EACJ,CAAC;;EAED;EACA,IAAK,CAAEnE,UAAU,EAAEgE,MAAM,EAAG;IAC3B,OAAO,IAAI;EACZ;EAEA,MAAMI,SAAS,GAAG,yCAAyC;;EAE3D;EACA,MAAMC,WAAW,GAAGrE,UAAU,CAACgE,MAAM,GAAG,CAAC;EAEzC,MAAMM,eAAe,GAAGD,WAAW,GAChCzE,iBAAiB,GACjByC,4BAA4B;EAE/B,MAAMkC,SAAS,GAAGf,cAAc,GAAGc,eAAe,GAAGjD,kBAAkB;EAEvE,oBACC,IAAA1B,WAAA,CAAAQ,GAAA,EAACoE,SAAS;IACT1E,SAAS,EAAGuE,SAAW;IACvBtE,iBAAiB,EAAGA,iBAAmB;IACvCC,aAAa,EAAGA,aAAe;IAC/BC,UAAU,EAAGA;EAAY,CACzB,CAAC;AAEJ;AAAC,IAAAwE,QAAA,GAAAC,OAAA,CAAA7D,OAAA,GAEc+B,sCAAsC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_i18n","_components","_data","_element","_icons","_blockIcon","_interopRequireDefault","_store","_jsxRuntime","VariationsButtons","className","onSelectVariation","selectedValue","variations","jsxs","children","jsx","VisuallyHidden","as","__","map","variation","Button","__next40pxDefaultSize","icon","default","showColors","isPressed","name","label","title","sprintf","onClick","showTooltip","VariationsDropdown","selectOptions","description","value","info","DropdownMenu","text","popoverProps","position","chevronDown","toggleProps","iconPosition","MenuGroup","MenuItemsChoice","choices","onSelect","VariationsToggleGroupControl","__experimentalToggleGroupControl","hideLabelFromVision","onChange","__nextHasNoMarginBottom","__experimentalToggleGroupControlOptionIcon","__experimentalBlockVariationTransforms","blockClientId","updateBlockAttributes","useDispatch","blockEditorStore","activeBlockVariation","isContentOnly","useSelect","select","getActiveBlockVariation","getBlockVariations","__experimentalHasContentRoleAttribute","blocksStore","getBlockName","getBlockAttributes","getBlockEditingMode","isContentBlock","hasUniqueIcons","useMemo","variationIcons","Set","forEach","add","src","size","length","variationName","find","attributes","baseClass","showButtons","ButtonComponent","Component","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-variation-transforms/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\n\nfunction VariationsButtons( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<fieldset className={ className }>\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\ticon={ <BlockIcon icon={ variation.icon } showColors /> }\n\t\t\t\t\tisPressed={ selectedValue === variation.name }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the block variation */\n\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\tvariation.title\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => onSelectVariation( variation.name ) }\n\t\t\t\t\taria-label={ variation.title }\n\t\t\t\t\tshowTooltip\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</fieldset>\n\t);\n}\n\nfunction VariationsDropdown( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\tconst selectOptions = variations.map(\n\t\t( { name, title, description } ) => ( {\n\t\t\tvalue: name,\n\t\t\tlabel: title,\n\t\t\tinfo: description,\n\t\t} )\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName={ className }\n\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\ttext={ __( 'Transform to variation' ) }\n\t\t\tpopoverProps={ {\n\t\t\t\tposition: 'bottom center',\n\t\t\t\tclassName: `${ className }__popover`,\n\t\t\t} }\n\t\t\ticon={ chevronDown }\n\t\t\ttoggleProps={ { iconPosition: 'right' } }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<div className={ `${ className }__container` }>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tchoices={ selectOptions }\n\t\t\t\t\t\t\tvalue={ selectedValue }\n\t\t\t\t\t\t\tonSelect={ onSelectVariation }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction VariationsToggleGroupControl( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\t\tvalue={ selectedValue }\n\t\t\t\thideLabelFromVision\n\t\t\t\tonChange={ onSelectVariation }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t>\n\t\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<BlockIcon icon={ variation.icon } showColors />\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ variation.name }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the block variation */\n\t\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\t\tvariation.title\n\t\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</ToggleGroupControl>\n\t\t</div>\n\t);\n}\n\nfunction __experimentalBlockVariationTransforms( { blockClientId } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { activeBlockVariation, variations, isContentOnly } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetActiveBlockVariation,\n\t\t\t\tgetBlockVariations,\n\t\t\t\t__experimentalHasContentRoleAttribute,\n\t\t\t} = select( blocksStore );\n\t\t\tconst { getBlockName, getBlockAttributes, getBlockEditingMode } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst name = blockClientId && getBlockName( blockClientId );\n\n\t\t\tconst isContentBlock =\n\t\t\t\t__experimentalHasContentRoleAttribute( name );\n\n\t\t\treturn {\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tgetBlockAttributes( blockClientId )\n\t\t\t\t),\n\t\t\t\tvariations: name && getBlockVariations( name, 'transform' ),\n\t\t\t\tisContentOnly:\n\t\t\t\t\tgetBlockEditingMode( blockClientId ) === 'contentOnly' &&\n\t\t\t\t\t! isContentBlock,\n\t\t\t};\n\t\t},\n\t\t[ blockClientId ]\n\t);\n\n\tconst selectedValue = activeBlockVariation?.name;\n\n\t// Check if each variation has a unique icon.\n\tconst hasUniqueIcons = useMemo( () => {\n\t\tconst variationIcons = new Set();\n\t\tif ( ! variations ) {\n\t\t\treturn false;\n\t\t}\n\t\tvariations.forEach( ( variation ) => {\n\t\t\tif ( variation.icon ) {\n\t\t\t\tvariationIcons.add( variation.icon?.src || variation.icon );\n\t\t\t}\n\t\t} );\n\t\treturn variationIcons.size === variations.length;\n\t}, [ variations ] );\n\n\tconst onSelectVariation = ( variationName ) => {\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\t...variations.find( ( { name } ) => name === variationName )\n\t\t\t\t.attributes,\n\t\t} );\n\t};\n\n\tif ( ! variations?.length || isContentOnly ) {\n\t\treturn null;\n\t}\n\n\tconst baseClass = 'block-editor-block-variation-transforms';\n\n\t// Show buttons if there are more than 5 variations because the ToggleGroupControl does not wrap\n\tconst showButtons = variations.length > 5;\n\n\tconst ButtonComponent = showButtons\n\t\t? VariationsButtons\n\t\t: VariationsToggleGroupControl;\n\n\tconst Component = hasUniqueIcons ? ButtonComponent : VariationsDropdown;\n\n\treturn (\n\t\t<Component\n\t\t\tclassName={ baseClass }\n\t\t\tonSelectVariation={ onSelectVariation }\n\t\t\tselectedValue={ selectedValue }\n\t\t\tvariations={ variations }\n\t\t/>\n\t);\n}\n\nexport default __experimentalBlockVariationTransforms;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAAwD,IAAAS,WAAA,GAAAT,OAAA;AAtBxD;AACA;AACA;;AAgBA;AACA;AACA;;AAIA,SAASU,iBAAiBA,CAAE;EAC3BC,SAAS;EACTC,iBAAiB;EACjBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,oBACC,IAAAL,WAAA,CAAA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e;IAC/BC,UAAU,EAAGA;EAAY,CACzB,CAAC;AAEJ;AAAC,IAAA4E,QAAA,GAAAC,OAAA,CAAAjE,OAAA,GAEc+B,sCAAsC","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ var _data = require("@wordpress/data");
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
var _icons = require("@wordpress/icons");
|
|
12
12
|
var _store = require("../../store");
|
|
13
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
15
|
/**
|
|
15
16
|
* WordPress dependencies
|
|
@@ -32,7 +33,7 @@ function ToolSelector(props, ref) {
|
|
|
32
33
|
const mode = (0, _data.useSelect)(select => select(_store.store).__unstableGetEditorMode(), []);
|
|
33
34
|
const {
|
|
34
35
|
__unstableSetEditorMode
|
|
35
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
36
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
36
37
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
|
|
37
38
|
renderToggle: ({
|
|
38
39
|
isOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_data","_element","_icons","_store","_jsxRuntime","selectIcon","jsx","SVG","xmlns","width","height","viewBox","children","Path","d","ToolSelector","props","ref","mode","useSelect","select","blockEditorStore","__unstableGetEditorMode","__unstableSetEditorMode","useDispatch","Dropdown","renderToggle","isOpen","onToggle","Button","__next40pxDefaultSize","icon","editIcon","onClick","label","__","popoverProps","placement","renderContent","jsxs","Fragment","NavigableMenu","role","MenuItemsChoice","value","onSelect","choices","Icon","className","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/tool-selector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tButton,\n\tMenuItemsChoice,\n\tSVG,\n\tPath,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, edit as editIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst selectIcon = (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t>\n\t\t<Path d=\"M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z\" />\n\t</SVG>\n);\n\nfunction ToolSelector( props, ref ) {\n\tconst mode = useSelect(\n\t\t( select ) => select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t[]\n\t);\n\tconst { __unstableSetEditorMode } =
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_data","_element","_icons","_store","_lockUnlock","_jsxRuntime","selectIcon","jsx","SVG","xmlns","width","height","viewBox","children","Path","d","ToolSelector","props","ref","mode","useSelect","select","blockEditorStore","__unstableGetEditorMode","__unstableSetEditorMode","unlock","useDispatch","Dropdown","renderToggle","isOpen","onToggle","Button","__next40pxDefaultSize","icon","editIcon","onClick","label","__","popoverProps","placement","renderContent","jsxs","Fragment","NavigableMenu","role","MenuItemsChoice","value","onSelect","choices","Icon","className","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/tool-selector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tButton,\n\tMenuItemsChoice,\n\tSVG,\n\tPath,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, edit as editIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst selectIcon = (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t>\n\t\t<Path d=\"M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z\" />\n\t</SVG>\n);\n\nfunction ToolSelector( props, ref ) {\n\tconst mode = useSelect(\n\t\t( select ) => select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t[]\n\t);\n\tconst { __unstableSetEditorMode } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ mode === 'navigation' ? selectIcon : editIcon }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\tlabel={ __( 'Tools' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\trenderContent={ () => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu role=\"menu\" aria-label={ __( 'Tools' ) }>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tmode === 'navigation' ? 'navigation' : 'edit'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={ __unstableSetEditorMode }\n\t\t\t\t\t\t\tchoices={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'edit',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ editIcon } />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t</>\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{\n\t\t\t\t\t\t\t\t\tvalue: 'navigation',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ selectIcon }\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Select' ) }\n\t\t\t\t\t\t\t\t\t\t</>\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] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolSelector );\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA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,8 +147,8 @@ const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.c
|
|
|
147
147
|
let values = {};
|
|
148
148
|
if (!source.getValues) {
|
|
149
149
|
Object.keys(bindings).forEach(attr => {
|
|
150
|
-
// Default to the
|
|
151
|
-
values[attr] =
|
|
150
|
+
// Default to the the source label when `getValues` doesn't exist.
|
|
151
|
+
values[attr] = source.label;
|
|
152
152
|
});
|
|
153
153
|
} else {
|
|
154
154
|
values = source.getValues({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_isUrlLike","_interopRequireDefault","_lockUnlock","_blockContext","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","getBindableAttributes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","blockContext","useContext","BlockContext","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","hasParentPattern","context","hasPatternOverridesDefaultBinding","attributes","metadata","blockBindings","useMemo","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","set","get","size","usesContext","length","key","values","getValues","keys","forEach","attr","label","value","isURLLike","setAttributes","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","newValue","setValues","caption","href","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from '../components/link-control/is-url-like';\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId } = props;\n\t\tconst hasParentPattern = !! props.context[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst boundAttributes = useSelect( () => {\n\t\t\tif ( ! blockBindings ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst attributes = {};\n\n\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\tblockBindings\n\t\t\t) ) {\n\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\tif ( ! source || ! canBindAttribute( name, attributeName ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\tfor ( const [ source, bindings ] of blockBindingsBySource ) {\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tconst context = {};\n\n\t\t\t\t\tif ( source.usesContext?.length ) {\n\t\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\tlet values = {};\n\t\t\t\t\tif ( ! source.getValues ) {\n\t\t\t\t\t\tObject.keys( bindings ).forEach( ( attr ) => {\n\t\t\t\t\t\t\t// Default to the `key` or the source label when `getValues` doesn't exist\n\t\t\t\t\t\t\tvalues[ attr ] =\n\t\t\t\t\t\t\t\tbindings[ attr ].args?.key || source.label;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalues = source.getValues( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\tvalues\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tattributeName === 'url' &&\n\t\t\t\t\t\t\t( ! value || ! isURLLike( value ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Return null if value is not a valid URL.\n\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tattributes[ attributeName ] = value;\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\treturn attributes;\n\t\t}, [ blockBindings, name, clientId, blockContext, registry, sources ] );\n\n\t\tconst { setAttributes } = props;\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\t// Populate context.\n\t\t\t\t\t\t\tconst context = {};\n\n\t\t\t\t\t\t\tif ( source.usesContext?.length ) {\n\t\t\t\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tblockContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAF,sBAAA,CAAAN,OAAA;AAAuD,IAAAS,WAAA,GAAAT,OAAA;AAdvD;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAEA,MAAMU,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KA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C,EACD,yBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASY,mBAAmBA,CAAEC,QAAQ,EAAE9C,IAAI,EAAG;EAC9C,IAAK,CAAEpB,YAAY,CAAEoB,IAAK,CAAC,EAAG;IAC7B,OAAO8C,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAE/D,uBAAuB,CAAE8D,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEA,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_isUrlLike","_interopRequireDefault","_lockUnlock","_blockContext","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","getBindableAttributes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","blockContext","useContext","BlockContext","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","hasParentPattern","context","hasPatternOverridesDefaultBinding","attributes","metadata","blockBindings","useMemo","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","set","get","size","usesContext","length","key","values","getValues","keys","forEach","attr","label","value","isURLLike","setAttributes","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","newValue","setValues","caption","href","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from '../components/link-control/is-url-like';\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId } = props;\n\t\tconst hasParentPattern = !! props.context[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst boundAttributes = useSelect( () => {\n\t\t\tif ( ! blockBindings ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst attributes = {};\n\n\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\tblockBindings\n\t\t\t) ) {\n\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\tif ( ! source || ! canBindAttribute( name, attributeName ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\tfor ( const [ source, bindings ] of blockBindingsBySource ) {\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tconst context = {};\n\n\t\t\t\t\tif ( source.usesContext?.length ) {\n\t\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\tlet values = {};\n\t\t\t\t\tif ( ! source.getValues ) {\n\t\t\t\t\t\tObject.keys( bindings ).forEach( ( attr ) => {\n\t\t\t\t\t\t\t// Default to the the source label when `getValues` doesn't exist.\n\t\t\t\t\t\t\tvalues[ attr ] = source.label;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalues = source.getValues( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\tvalues\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tattributeName === 'url' &&\n\t\t\t\t\t\t\t( ! value || ! isURLLike( value ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Return null if value is not a valid URL.\n\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tattributes[ attributeName ] = value;\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\treturn attributes;\n\t\t}, [ blockBindings, name, clientId, blockContext, registry, sources ] );\n\n\t\tconst { setAttributes } = props;\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\t// Populate context.\n\t\t\t\t\t\t\tconst context = {};\n\n\t\t\t\t\t\t\tif ( source.usesContext?.length ) {\n\t\t\t\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tblockContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAF,sBAAA,CAAAN,OAAA;AAAuD,IAAAS,WAAA,GAAAT,OAAA;AAdvD;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAEA,MAAMU,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,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AACA;AACA;AACA;AACA;AACA;AACA,SAASY,mBAAmBA,CAAEC,QAAQ,EAAE9C,IAAI,EAAG;EAC9C,IAAK,CAAEpB,YAAY,CAAEoB,IAAK,CAAC,EAAG;IAC7B,OAAO8C,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAE/D,uBAAuB,CAAE8D,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEA,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ exports.useZoomOut = useZoomOut;
|
|
|
7
7
|
var _data = require("@wordpress/data");
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
var _store = require("../store");
|
|
10
|
+
var _lockUnlock = require("../lock-unlock");
|
|
10
11
|
/**
|
|
11
12
|
* WordPress dependencies
|
|
12
13
|
*/
|
|
@@ -16,39 +17,35 @@ var _store = require("../store");
|
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
* A hook used to set the
|
|
20
|
+
* A hook used to set the zoomed out view, invoking the hook sets the mode.
|
|
20
21
|
*
|
|
21
|
-
* @param {boolean} zoomOut If we should
|
|
22
|
+
* @param {boolean} zoomOut If we should zoom out or not.
|
|
22
23
|
*/
|
|
23
24
|
function useZoomOut(zoomOut = true) {
|
|
24
25
|
const {
|
|
25
|
-
|
|
26
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
26
|
+
setZoomLevel
|
|
27
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
27
28
|
const {
|
|
28
|
-
|
|
29
|
-
} = (0, _data.useSelect)(_store.store);
|
|
30
|
-
const
|
|
31
|
-
const mode = __unstableGetEditorMode();
|
|
29
|
+
isZoomOut
|
|
30
|
+
} = (0, _lockUnlock.unlock)((0, _data.useSelect)(_store.store));
|
|
31
|
+
const originalIsZoomOutRef = (0, _element.useRef)(null);
|
|
32
32
|
(0, _element.useEffect)(() => {
|
|
33
33
|
// Only set this on mount so we know what to return to when we unmount.
|
|
34
|
-
if (!
|
|
35
|
-
|
|
34
|
+
if (!originalIsZoomOutRef.current) {
|
|
35
|
+
originalIsZoomOutRef.current = isZoomOut();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The effect opens the zoom-out view if we want it open and the canvas is not currently zoomed-out.
|
|
39
|
+
if (zoomOut && isZoomOut() === false) {
|
|
40
|
+
setZoomLevel(50);
|
|
41
|
+
} else if (!zoomOut && isZoomOut() && originalIsZoomOutRef.current !== isZoomOut()) {
|
|
42
|
+
setZoomLevel(originalIsZoomOutRef.current ? 50 : 100);
|
|
36
43
|
}
|
|
37
44
|
return () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
__unstableSetEditorMode(originalEditingModeRef.current);
|
|
45
|
+
if (isZoomOut() && isZoomOut() !== originalIsZoomOutRef.current) {
|
|
46
|
+
setZoomLevel(originalIsZoomOutRef.current ? 50 : 100);
|
|
41
47
|
}
|
|
42
48
|
};
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
// The effect opens the zoom-out view if we want it open and it's not currently in zoom-out mode.
|
|
46
|
-
(0, _element.useEffect)(() => {
|
|
47
|
-
if (zoomOut && mode !== 'zoom-out') {
|
|
48
|
-
__unstableSetEditorMode('zoom-out');
|
|
49
|
-
} else if (!zoomOut && __unstableGetEditorMode() === 'zoom-out' && originalEditingModeRef.current !== mode) {
|
|
50
|
-
__unstableSetEditorMode(originalEditingModeRef.current);
|
|
51
|
-
}
|
|
52
|
-
}, [__unstableGetEditorMode, __unstableSetEditorMode, zoomOut]); // Mode is deliberately excluded from the dependencies so that the effect does not run when mode changes.
|
|
49
|
+
}, [isZoomOut, setZoomLevel, zoomOut]);
|
|
53
50
|
}
|
|
54
51
|
//# sourceMappingURL=use-zoom-out.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_element","_store","useZoomOut","zoomOut","
|
|
1
|
+
{"version":3,"names":["_data","require","_element","_store","_lockUnlock","useZoomOut","zoomOut","setZoomLevel","unlock","useDispatch","blockEditorStore","isZoomOut","useSelect","originalIsZoomOutRef","useRef","useEffect","current"],"sources":["@wordpress/block-editor/src/hooks/use-zoom-out.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * A hook used to set the zoomed out view, invoking the hook sets the mode.\n *\n * @param {boolean} zoomOut If we should zoom out or not.\n */\nexport function useZoomOut( zoomOut = true ) {\n\tconst { setZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\tconst { isZoomOut } = unlock( useSelect( blockEditorStore ) );\n\n\tconst originalIsZoomOutRef = useRef( null );\n\n\tuseEffect( () => {\n\t\t// Only set this on mount so we know what to return to when we unmount.\n\t\tif ( ! originalIsZoomOutRef.current ) {\n\t\t\toriginalIsZoomOutRef.current = isZoomOut();\n\t\t}\n\n\t\t// The effect opens the zoom-out view if we want it open and the canvas is not currently zoomed-out.\n\t\tif ( zoomOut && isZoomOut() === false ) {\n\t\t\tsetZoomLevel( 50 );\n\t\t} else if (\n\t\t\t! zoomOut &&\n\t\t\tisZoomOut() &&\n\t\t\toriginalIsZoomOutRef.current !== isZoomOut()\n\t\t) {\n\t\t\tsetZoomLevel( originalIsZoomOutRef.current ? 50 : 100 );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isZoomOut() && isZoomOut() !== originalIsZoomOutRef.current ) {\n\t\t\t\tsetZoomLevel( originalIsZoomOutRef.current ? 50 : 100 );\n\t\t\t}\n\t\t};\n\t}, [ isZoomOut, setZoomLevel, zoomOut ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAA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
|
exports.hideBlockInterface = hideBlockInterface;
|
|
12
12
|
exports.privateRemoveBlocks = exports.modifyContentLockBlock = void 0;
|
|
13
|
+
exports.resetZoomLevel = resetZoomLevel;
|
|
13
14
|
exports.setBlockRemovalRules = setBlockRemovalRules;
|
|
14
15
|
exports.setLastFocus = setLastFocus;
|
|
15
16
|
exports.setOpenedBlockSettingsMenu = setOpenedBlockSettingsMenu;
|
|
16
17
|
exports.setStyleOverride = setStyleOverride;
|
|
18
|
+
exports.setZoomLevel = setZoomLevel;
|
|
17
19
|
exports.showBlockInterface = showBlockInterface;
|
|
18
20
|
exports.startDragging = startDragging;
|
|
19
21
|
exports.stopDragging = stopDragging;
|
|
@@ -402,5 +404,28 @@ const modifyContentLockBlock = clientId => ({
|
|
|
402
404
|
});
|
|
403
405
|
dispatch.__unstableSetTemporarilyEditingAsBlocks(clientId, focusModeToRevert);
|
|
404
406
|
};
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Sets the zoom level.
|
|
410
|
+
*
|
|
411
|
+
* @param {number} zoom the new zoom level
|
|
412
|
+
* @return {Object} Action object.
|
|
413
|
+
*/
|
|
405
414
|
exports.modifyContentLockBlock = modifyContentLockBlock;
|
|
415
|
+
function setZoomLevel(zoom = 100) {
|
|
416
|
+
return {
|
|
417
|
+
type: 'SET_ZOOM_LEVEL',
|
|
418
|
+
zoom
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Resets the Zoom state.
|
|
424
|
+
* @return {Object} Action object.
|
|
425
|
+
*/
|
|
426
|
+
function resetZoomLevel() {
|
|
427
|
+
return {
|
|
428
|
+
type: 'RESET_ZOOM_LEVEL'
|
|
429
|
+
};
|
|
430
|
+
}
|
|
406
431
|
//# sourceMappingURL=private-actions.js.map
|