@wordpress/block-editor 14.16.0 → 14.18.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 +4 -0
- package/build/components/background-image-control/index.js +18 -10
- package/build/components/background-image-control/index.js.map +1 -1
- package/build/components/block-canvas/index.js +6 -3
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +14 -11
- package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +3 -3
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-toolbar/use-has-block-toolbar.js +3 -12
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +3 -2
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/child-layout-control/index.js +1 -0
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/html-element-control/index.js +107 -0
- package/build/components/html-element-control/index.js.map +1 -0
- package/build/components/html-element-control/messages.js +25 -0
- package/build/components/html-element-control/messages.js.map +1 -0
- package/build/components/inserter/media-tab/media-preview.js +1 -7
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/link-control/index.js +2 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -1
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/delete.js +1 -9
- package/build/components/rich-text/event-listeners/delete.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/hooks/duotone.js +1 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +14 -8
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +4 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build-module/components/background-image-control/index.js +19 -11
- package/build-module/components/background-image-control/index.js.map +1 -1
- package/build-module/components/block-canvas/index.js +6 -3
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-list/block.js +4 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +14 -11
- package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +3 -3
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +3 -12
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +3 -2
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +1 -0
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/html-element-control/index.js +102 -0
- package/build-module/components/html-element-control/index.js.map +1 -0
- package/build-module/components/html-element-control/messages.js +19 -0
- package/build-module/components/html-element-control/messages.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-preview.js +1 -7
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +2 -2
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/link-control/index.js +4 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -1
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/delete.js +1 -9
- package/build-module/components/rich-text/event-listeners/delete.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/hooks/duotone.js +1 -1
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +15 -9
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +3 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +7 -2
- package/build-style/style.css +8 -2
- package/package.json +34 -34
- package/src/components/background-image-control/index.js +22 -7
- package/src/components/block-canvas/index.js +5 -3
- package/src/components/block-inspector/style.scss +4 -2
- package/src/components/block-list/block.js +6 -2
- package/src/components/block-list/content.scss +1 -0
- package/src/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +14 -11
- package/src/components/block-settings-menu/block-mode-toggle.js +3 -3
- package/src/components/block-settings-menu/test/block-mode-toggle.js +1 -1
- package/src/components/block-toolbar/use-has-block-toolbar.js +7 -13
- package/src/components/block-tools/use-show-block-tools.js +2 -0
- package/src/components/child-layout-control/index.js +1 -0
- package/src/components/html-element-control/index.js +109 -0
- package/src/components/html-element-control/messages.js +34 -0
- package/src/components/inserter/media-tab/media-preview.js +1 -8
- package/src/components/keyboard-shortcuts/index.js +2 -2
- package/src/components/link-control/index.js +6 -1
- package/src/components/media-placeholder/index.js +1 -1
- package/src/components/media-placeholder/style.scss +6 -0
- package/src/components/rich-text/event-listeners/delete.js +1 -6
- package/src/components/use-resize-canvas/index.js +1 -1
- package/src/hooks/duotone.js +4 -3
- package/src/hooks/spacing-visualizer.js +14 -17
- package/src/hooks/typography.js +5 -3
- package/src/private-apis.js +2 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +5 -1
- package/src/store/test/actions.js +122 -0
|
@@ -47,12 +47,15 @@ function down(event) {
|
|
|
47
47
|
} = event;
|
|
48
48
|
const {
|
|
49
49
|
ownerDocument,
|
|
50
|
-
isContentEditable
|
|
50
|
+
isContentEditable,
|
|
51
|
+
tagName
|
|
51
52
|
} = target;
|
|
53
|
+
const isInputOrTextArea = ['INPUT', 'TEXTAREA'].includes(tagName);
|
|
52
54
|
const nodes = nodesByDocument.get(ownerDocument);
|
|
53
|
-
if (isContentEditable) {
|
|
54
|
-
// Whenever an editable element is clicked,
|
|
55
|
-
// blocks contain this element, and temporarily
|
|
55
|
+
if (isContentEditable || isInputOrTextArea) {
|
|
56
|
+
// Whenever an editable element or an input or textarea is clicked,
|
|
57
|
+
// check which draggable blocks contain this element, and temporarily
|
|
58
|
+
// disable draggability.
|
|
56
59
|
for (const node of nodes) {
|
|
57
60
|
if (node.getAttribute('draggable') === 'true' && node.contains(target)) {
|
|
58
61
|
node.removeAttribute('draggable');
|
|
@@ -60,8 +63,8 @@ function down(event) {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
} else {
|
|
63
|
-
// Whenever a non-editable element is clicked,
|
|
64
|
-
// for any blocks that were previously disabled.
|
|
66
|
+
// Whenever a non-editable element or an input or textarea is clicked,
|
|
67
|
+
// re-enable draggability for any blocks that were previously disabled.
|
|
65
68
|
for (const node of nodes) {
|
|
66
69
|
restore(node);
|
|
67
70
|
}
|
|
@@ -69,11 +72,11 @@ function down(event) {
|
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
/**
|
|
72
|
-
* In Firefox, the `draggable` and `contenteditable`
|
|
73
|
-
* together. When
|
|
74
|
-
* doesn't get set in the right place. The only
|
|
75
|
-
* remove the `draggable` attribute clicking inside
|
|
76
|
-
*
|
|
75
|
+
* In Firefox, the `draggable` and `contenteditable` or `input` or `textarea`
|
|
76
|
+
* elements don't play well together. When these elements are within a
|
|
77
|
+
* `draggable` element, selection doesn't get set in the right place. The only
|
|
78
|
+
* solution is to temporarily remove the `draggable` attribute clicking inside
|
|
79
|
+
* these elements.
|
|
77
80
|
* @return {Function} Cleanup function.
|
|
78
81
|
*/
|
|
79
82
|
function useFirefoxDraggableCompatibility() {
|
package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","nodesByDocument","Map","add","doc","node","set","get","Set","addEventListener","down","remove","delete","restore","size","removeEventListener","prevDraggable","getAttribute","removeAttribute","setAttribute","event","target","ownerDocument","isContentEditable","nodes","contains","useFirefoxDraggableCompatibility","useRefEffect"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-firefox-draggable-compatibility.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\nconst nodesByDocument = new Map();\n\nfunction add( doc, node ) {\n\tlet set = nodesByDocument.get( doc );\n\tif ( ! set ) {\n\t\tset = new Set();\n\t\tnodesByDocument.set( doc, set );\n\t\tdoc.addEventListener( 'pointerdown', down );\n\t}\n\tset.add( node );\n}\n\nfunction remove( doc, node ) {\n\tconst set = nodesByDocument.get( doc );\n\tif ( set ) {\n\t\tset.delete( node );\n\t\trestore( node );\n\t\tif ( set.size === 0 ) {\n\t\t\tnodesByDocument.delete( doc );\n\t\t\tdoc.removeEventListener( 'pointerdown', down );\n\t\t}\n\t}\n}\n\nfunction restore( node ) {\n\tconst prevDraggable = node.getAttribute( 'data-draggable' );\n\tif ( prevDraggable ) {\n\t\tnode.removeAttribute( 'data-draggable' );\n\t\t// Only restore if `draggable` is still removed. It could have been\n\t\t// changed by React in the meantime.\n\t\tif ( prevDraggable === 'true' && ! node.getAttribute( 'draggable' ) ) {\n\t\t\tnode.setAttribute( 'draggable', 'true' );\n\t\t}\n\t}\n}\n\nfunction down( event ) {\n\tconst { target } = event;\n\tconst { ownerDocument, isContentEditable } = target;\n\tconst nodes = nodesByDocument.get( ownerDocument );\n\n\tif ( isContentEditable ) {\n\t\t// Whenever an editable element
|
|
1
|
+
{"version":3,"names":["_compose","require","nodesByDocument","Map","add","doc","node","set","get","Set","addEventListener","down","remove","delete","restore","size","removeEventListener","prevDraggable","getAttribute","removeAttribute","setAttribute","event","target","ownerDocument","isContentEditable","tagName","isInputOrTextArea","includes","nodes","contains","useFirefoxDraggableCompatibility","useRefEffect"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-firefox-draggable-compatibility.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\nconst nodesByDocument = new Map();\n\nfunction add( doc, node ) {\n\tlet set = nodesByDocument.get( doc );\n\tif ( ! set ) {\n\t\tset = new Set();\n\t\tnodesByDocument.set( doc, set );\n\t\tdoc.addEventListener( 'pointerdown', down );\n\t}\n\tset.add( node );\n}\n\nfunction remove( doc, node ) {\n\tconst set = nodesByDocument.get( doc );\n\tif ( set ) {\n\t\tset.delete( node );\n\t\trestore( node );\n\t\tif ( set.size === 0 ) {\n\t\t\tnodesByDocument.delete( doc );\n\t\t\tdoc.removeEventListener( 'pointerdown', down );\n\t\t}\n\t}\n}\n\nfunction restore( node ) {\n\tconst prevDraggable = node.getAttribute( 'data-draggable' );\n\tif ( prevDraggable ) {\n\t\tnode.removeAttribute( 'data-draggable' );\n\t\t// Only restore if `draggable` is still removed. It could have been\n\t\t// changed by React in the meantime.\n\t\tif ( prevDraggable === 'true' && ! node.getAttribute( 'draggable' ) ) {\n\t\t\tnode.setAttribute( 'draggable', 'true' );\n\t\t}\n\t}\n}\n\nfunction down( event ) {\n\tconst { target } = event;\n\tconst { ownerDocument, isContentEditable, tagName } = target;\n\tconst isInputOrTextArea = [ 'INPUT', 'TEXTAREA' ].includes( tagName );\n\n\tconst nodes = nodesByDocument.get( ownerDocument );\n\n\tif ( isContentEditable || isInputOrTextArea ) {\n\t\t// Whenever an editable element or an input or textarea is clicked,\n\t\t// check which draggable blocks contain this element, and temporarily\n\t\t// disable draggability.\n\t\tfor ( const node of nodes ) {\n\t\t\tif (\n\t\t\t\tnode.getAttribute( 'draggable' ) === 'true' &&\n\t\t\t\tnode.contains( target )\n\t\t\t) {\n\t\t\t\tnode.removeAttribute( 'draggable' );\n\t\t\t\tnode.setAttribute( 'data-draggable', 'true' );\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// Whenever a non-editable element or an input or textarea is clicked,\n\t\t// re-enable draggability for any blocks that were previously disabled.\n\t\tfor ( const node of nodes ) {\n\t\t\trestore( node );\n\t\t}\n\t}\n}\n\n/**\n * In Firefox, the `draggable` and `contenteditable` or `input` or `textarea`\n * elements don't play well together. When these elements are within a\n * `draggable` element, selection doesn't get set in the right place. The only\n * solution is to temporarily remove the `draggable` attribute clicking inside\n * these elements.\n * @return {Function} Cleanup function.\n */\nexport function useFirefoxDraggableCompatibility() {\n\treturn useRefEffect( ( node ) => {\n\t\tadd( node.ownerDocument, node );\n\t\treturn () => {\n\t\t\tremove( node.ownerDocument, node );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC;AAEjC,SAASC,GAAGA,CAAEC,GAAG,EAAEC,IAAI,EAAG;EACzB,IAAIC,GAAG,GAAGL,eAAe,CAACM,GAAG,CAAEH,GAAI,CAAC;EACpC,IAAK,CAAEE,GAAG,EAAG;IACZA,GAAG,GAAG,IAAIE,GAAG,CAAC,CAAC;IACfP,eAAe,CAACK,GAAG,CAAEF,GAAG,EAAEE,GAAI,CAAC;IAC/BF,GAAG,CAACK,gBAAgB,CAAE,aAAa,EAAEC,IAAK,CAAC;EAC5C;EACAJ,GAAG,CAACH,GAAG,CAAEE,IAAK,CAAC;AAChB;AAEA,SAASM,MAAMA,CAAEP,GAAG,EAAEC,IAAI,EAAG;EAC5B,M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e,CAAE,WAAY,CAAC;QACnCb,IAAI,CAACc,YAAY,CAAE,gBAAgB,EAAE,MAAO,CAAC;MAC9C;IACD;EACD,CAAC,MAAM;IACN;IACA;IACA,KAAM,MAAMd,IAAI,IAAIsB,KAAK,EAAG;MAC3Bd,OAAO,CAAER,IAAK,CAAC;IAChB;EACD;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASwB,gCAAgCA,CAAA,EAAG;EAClD,OAAO,IAAAC,qBAAY,EAAIzB,IAAI,IAAM;IAChCF,GAAG,CAAEE,IAAI,CAACiB,aAAa,EAAEjB,IAAK,CAAC;IAC/B,OAAO,MAAM;MACZM,MAAM,CAAEN,IAAI,CAACiB,aAAa,EAAEjB,IAAK,CAAC;IACnC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
@@ -26,7 +26,7 @@ function BlockModeToggle({
|
|
|
26
26
|
const {
|
|
27
27
|
blockType,
|
|
28
28
|
mode,
|
|
29
|
-
|
|
29
|
+
enabled
|
|
30
30
|
} = (0, _data.useSelect)(select => {
|
|
31
31
|
const {
|
|
32
32
|
getBlock,
|
|
@@ -37,13 +37,13 @@ function BlockModeToggle({
|
|
|
37
37
|
return {
|
|
38
38
|
mode: getBlockMode(clientId),
|
|
39
39
|
blockType: block ? (0, _blocks.getBlockType)(block.name) : null,
|
|
40
|
-
|
|
40
|
+
enabled: getSettings().codeEditingEnabled && !!block?.isValid
|
|
41
41
|
};
|
|
42
42
|
}, [clientId]);
|
|
43
43
|
const {
|
|
44
44
|
toggleBlockMode
|
|
45
45
|
} = (0, _data.useDispatch)(_store.store);
|
|
46
|
-
if (!blockType || !(0, _blocks.hasBlockSupport)(blockType, 'html', true) || !
|
|
46
|
+
if (!blockType || !(0, _blocks.hasBlockSupport)(blockType, 'html', true) || !enabled) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
const label = mode === 'visual' ? (0, _i18n.__)('Edit as HTML') : (0, _i18n.__)('Edit visually');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_store","_jsxRuntime","noop","BlockModeToggle","clientId","onToggle","blockType","mode","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_store","_jsxRuntime","noop","BlockModeToggle","clientId","onToggle","blockType","mode","enabled","useSelect","select","getBlock","getBlockMode","getSettings","blockEditorStore","block","getBlockType","name","codeEditingEnabled","isValid","toggleBlockMode","useDispatch","hasBlockSupport","label","__","jsx","MenuItem","onClick","children"],"sources":["@wordpress/block-editor/src/components/block-settings-menu/block-mode-toggle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nexport default function BlockModeToggle( { clientId, onToggle = noop } ) {\n\tconst { blockType, mode, enabled } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockMode, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tblockType: block ? getBlockType( block.name ) : null,\n\t\t\t\tenabled: getSettings().codeEditingEnabled && !! block?.isValid,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { toggleBlockMode } = useDispatch( blockEditorStore );\n\n\tif (\n\t\t! blockType ||\n\t\t! hasBlockSupport( blockType, 'html', true ) ||\n\t\t! enabled\n\t) {\n\t\treturn null;\n\t}\n\n\tconst label =\n\t\tmode === 'visual' ? __( 'Edit as HTML' ) : __( 'Edit visually' );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\ttoggleBlockMode( clientId );\n\t\t\t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AQ,GAAG,IAAAiB,QAAE,EAAE,cAAe,CAAC,GAAG,IAAAA,QAAE,EAAE,eAAgB,CAAC;EAEjE,oBACC,IAAAvB,WAAA,CAAAwB,GAAA,EAAC5B,WAAA,CAAA6B,QAAQ;IACRC,OAAO,EAAGA,CAAA,KAAM;MACfP,eAAe,CAAEhB,QAAS,CAAC;MAC3BC,QAAQ,CAAC,CAAC;IACX,CAAG;IAAAuB,QAAA,EAEDL;EAAK,CACE,CAAC;AAEb","ignoreList":[]}
|
|
@@ -21,10 +21,7 @@ var _store = require("../../store");
|
|
|
21
21
|
* @return {boolean} Whether the block toolbar component will be rendered.
|
|
22
22
|
*/
|
|
23
23
|
function useHasBlockToolbar() {
|
|
24
|
-
const {
|
|
25
|
-
isToolbarEnabled,
|
|
26
|
-
isBlockDisabled
|
|
27
|
-
} = (0, _data.useSelect)(select => {
|
|
24
|
+
const enabled = (0, _data.useSelect)(select => {
|
|
28
25
|
const {
|
|
29
26
|
getBlockEditingMode,
|
|
30
27
|
getBlockName,
|
|
@@ -36,14 +33,8 @@ function useHasBlockToolbar() {
|
|
|
36
33
|
// instead of getSelectedBlockClientIds
|
|
37
34
|
const selectedBlockClientId = getBlockSelectionStart();
|
|
38
35
|
const blockType = selectedBlockClientId && (0, _blocks.getBlockType)(getBlockName(selectedBlockClientId));
|
|
39
|
-
return
|
|
40
|
-
isToolbarEnabled: blockType && (0, _blocks.hasBlockSupport)(blockType, '__experimentalToolbar', true),
|
|
41
|
-
isBlockDisabled: getBlockEditingMode(selectedBlockClientId) === 'disabled'
|
|
42
|
-
};
|
|
36
|
+
return blockType && (0, _blocks.hasBlockSupport)(blockType, '__experimentalToolbar', true) && getBlockEditingMode(selectedBlockClientId) !== 'disabled';
|
|
43
37
|
}, []);
|
|
44
|
-
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
38
|
+
return enabled;
|
|
48
39
|
}
|
|
49
40
|
//# sourceMappingURL=use-has-block-toolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blocks","_store","useHasBlockToolbar","
|
|
1
|
+
{"version":3,"names":["_data","require","_blocks","_store","useHasBlockToolbar","enabled","useSelect","select","getBlockEditingMode","getBlockName","getBlockSelectionStart","blockEditorStore","selectedBlockClientId","blockType","getBlockType","hasBlockSupport"],"sources":["@wordpress/block-editor/src/components/block-toolbar/use-has-block-toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Returns true if the block toolbar should be shown.\n *\n * @return {boolean} Whether the block toolbar component will be rendered.\n */\nexport function useHasBlockToolbar() {\n\tconst enabled = useSelect( ( select ) => {\n\t\tconst { getBlockEditingMode, getBlockName, getBlockSelectionStart } =\n\t\t\tselect( blockEditorStore );\n\n\t\t// we only care about the 1st selected block\n\t\t// for the toolbar, so we use getBlockSelectionStart\n\t\t// instead of getSelectedBlockClientIds\n\t\tconst selectedBlockClientId = getBlockSelectionStart();\n\n\t\tconst blockType =\n\t\t\tselectedBlockClientId &&\n\t\t\tgetBlockType( getBlockName( selectedBlockClientId ) );\n\n\t\treturn (\n\t\t\tblockType &&\n\t\t\thasBlockSupport( blockType, '__experimentalToolbar', true ) &&\n\t\t\tgetBlockEditingMode( selectedBlockClientId ) !== 'disabled'\n\t\t);\n\t}, [] );\n\n\treturn enabled;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAIA,IAAAE,MAAA,GAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAAA,EAAG;EACpC,MAAMC,OAAO,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACxC,MAAM;MAAEC,mBAAmB;MAAEC,YAAY;MAAEC;IAAuB,CAAC,GAClEH,MAAM,CAAEI,YAAiB,CAAC;;IAE3B;IACA;IACA;IACA,MAAMC,qBAAqB,GAAGF,sBAAsB,CAAC,CAAC;IAEtD,MAAMG,SAAS,GACdD,qBAAqB,IACrB,IAAAE,oBAAY,EAAEL,YAAY,CAAEG,qBAAsB,CAAE,CAAC;IAEtD,OACCC,SAAS,IACT,IAAAE,uBAAe,EAAEF,SAAS,EAAE,uBAAuB,EAAE,IAAK,CAAC,IAC3DL,mBAAmB,CAAEI,qBAAsB,CAAC,KAAK,UAAU;EAE7D,CAAC,EAAE,EAAG,CAAC;EAEP,OAAOP,OAAO;AACf","ignoreList":[]}
|
|
@@ -30,7 +30,8 @@ function useShowBlockTools() {
|
|
|
30
30
|
getBlockMode,
|
|
31
31
|
getSettings,
|
|
32
32
|
__unstableGetEditorMode,
|
|
33
|
-
isTyping
|
|
33
|
+
isTyping,
|
|
34
|
+
isBlockInterfaceHidden
|
|
34
35
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
35
36
|
const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
|
|
36
37
|
const block = getBlock(clientId);
|
|
@@ -41,7 +42,7 @@ function useShowBlockTools() {
|
|
|
41
42
|
// Hide the block inserter on the navigation mode.
|
|
42
43
|
// See https://github.com/WordPress/gutenberg/pull/66636#discussion_r1824728483.
|
|
43
44
|
editorMode !== 'navigation' && isEmptyDefaultBlock;
|
|
44
|
-
const _showBlockToolbarPopover = !getSettings().hasFixedToolbar && !_showEmptyBlockSideInserter && hasSelectedBlock && !isEmptyDefaultBlock;
|
|
45
|
+
const _showBlockToolbarPopover = !isBlockInterfaceHidden() && !getSettings().hasFixedToolbar && !_showEmptyBlockSideInserter && hasSelectedBlock && !isEmptyDefaultBlock;
|
|
45
46
|
return {
|
|
46
47
|
showEmptyBlockSideInserter: _showEmptyBlockSideInserter,
|
|
47
48
|
showBlockToolbarPopover: _showBlockToolbarPopover
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blocks","_store","_lockUnlock","useShowBlockTools","useSelect","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlock","getBlockMode","getSettings","__unstableGetEditorMode","isTyping","unlock","blockEditorStore","clientId","block","editorMode","hasSelectedBlock","isEmptyDefaultBlock","isUnmodifiedDefaultBlock","_showEmptyBlockSideInserter","_showBlockToolbarPopover","hasFixedToolbar","showEmptyBlockSideInserter","showBlockToolbarPopover"],"sources":["@wordpress/block-editor/src/components/block-tools/use-show-block-tools.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Source of truth for which block tools are showing in the block editor.\n *\n * @return {Object} Object of which block tools will be shown.\n */\nexport function useShowBlockTools() {\n\treturn useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetFirstMultiSelectedBlockClientId,\n\t\t\tgetBlock,\n\t\t\tgetBlockMode,\n\t\t\tgetSettings,\n\t\t\t__unstableGetEditorMode,\n\t\t\tisTyping,\n\t\t} = unlock( select( blockEditorStore ) );\n\n\t\tconst clientId =\n\t\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\t\tconst block = getBlock( clientId );\n\t\tconst editorMode = __unstableGetEditorMode();\n\t\tconst hasSelectedBlock = !! clientId && !! block;\n\t\tconst isEmptyDefaultBlock =\n\t\t\thasSelectedBlock &&\n\t\t\tisUnmodifiedDefaultBlock( block ) &&\n\t\t\tgetBlockMode( clientId ) !== 'html';\n\t\tconst _showEmptyBlockSideInserter =\n\t\t\tclientId &&\n\t\t\t! isTyping() &&\n\t\t\t// Hide the block inserter on the navigation mode.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/66636#discussion_r1824728483.\n\t\t\teditorMode !== 'navigation' &&\n\t\t\tisEmptyDefaultBlock;\n\t\tconst _showBlockToolbarPopover =\n\t\t\t! getSettings().hasFixedToolbar &&\n\t\t\t! _showEmptyBlockSideInserter &&\n\t\t\thasSelectedBlock &&\n\t\t\t! isEmptyDefaultBlock;\n\n\t\treturn {\n\t\t\tshowEmptyBlockSideInserter: _showEmptyBlockSideInserter,\n\t\t\tshowBlockToolbarPopover: _showBlockToolbarPopover,\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,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,iBAAiBA,CAAA,EAAG;EACnC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MACLC,wBAAwB;MACxBC,kCAAkC;MAClCC,QAAQ;MACRC,YAAY;MACZC,WAAW;MACXC,uBAAuB;MACvBC;IACD,CAAC,GAAG,IAAAC,kBAAM,
|
|
1
|
+
{"version":3,"names":["_data","require","_blocks","_store","_lockUnlock","useShowBlockTools","useSelect","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlock","getBlockMode","getSettings","__unstableGetEditorMode","isTyping","isBlockInterfaceHidden","unlock","blockEditorStore","clientId","block","editorMode","hasSelectedBlock","isEmptyDefaultBlock","isUnmodifiedDefaultBlock","_showEmptyBlockSideInserter","_showBlockToolbarPopover","hasFixedToolbar","showEmptyBlockSideInserter","showBlockToolbarPopover"],"sources":["@wordpress/block-editor/src/components/block-tools/use-show-block-tools.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Source of truth for which block tools are showing in the block editor.\n *\n * @return {Object} Object of which block tools will be shown.\n */\nexport function useShowBlockTools() {\n\treturn useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetFirstMultiSelectedBlockClientId,\n\t\t\tgetBlock,\n\t\t\tgetBlockMode,\n\t\t\tgetSettings,\n\t\t\t__unstableGetEditorMode,\n\t\t\tisTyping,\n\t\t\tisBlockInterfaceHidden,\n\t\t} = unlock( select( blockEditorStore ) );\n\n\t\tconst clientId =\n\t\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\t\tconst block = getBlock( clientId );\n\t\tconst editorMode = __unstableGetEditorMode();\n\t\tconst hasSelectedBlock = !! clientId && !! block;\n\t\tconst isEmptyDefaultBlock =\n\t\t\thasSelectedBlock &&\n\t\t\tisUnmodifiedDefaultBlock( block ) &&\n\t\t\tgetBlockMode( clientId ) !== 'html';\n\t\tconst _showEmptyBlockSideInserter =\n\t\t\tclientId &&\n\t\t\t! isTyping() &&\n\t\t\t// Hide the block inserter on the navigation mode.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/66636#discussion_r1824728483.\n\t\t\teditorMode !== 'navigation' &&\n\t\t\tisEmptyDefaultBlock;\n\t\tconst _showBlockToolbarPopover =\n\t\t\t! isBlockInterfaceHidden() &&\n\t\t\t! getSettings().hasFixedToolbar &&\n\t\t\t! _showEmptyBlockSideInserter &&\n\t\t\thasSelectedBlock &&\n\t\t\t! isEmptyDefaultBlock;\n\n\t\treturn {\n\t\t\tshowEmptyBlockSideInserter: _showEmptyBlockSideInserter,\n\t\t\tshowBlockToolbarPopover: _showBlockToolbarPopover,\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,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,iBAAiBA,CAAA,EAAG;EACnC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MACLC,wBAAwB;MACxBC,kCAAkC;MAClCC,QAAQ;MACRC,YAAY;MACZC,WAAW;MACXC,uBAAuB;MACvBC,QAAQ;MACRC;IACD,CAAC,GAAG,IAAAC,kBAAM,EAAET,MAAM,CAAEU,YAAiB,CAAE,CAAC;IAExC,MAAMC,QAAQ,GACbV,wBAAwB,CAAC,CAAC,IAAIC,kCAAkC,CAAC,CAAC;IAEnE,MAAMU,KAAK,GAAGT,QAAQ,CAAEQ,QAAS,CAAC;IAClC,MAAME,UAAU,GAAGP,uBAAuB,CAAC,CAAC;IAC5C,MAAMQ,gBAAgB,GAAG,CAAC,CAAEH,QAAQ,IAAI,CAAC,CAAEC,KAAK;IAChD,MAAMG,mBAAmB,GACxBD,gBAAgB,IAChB,IAAAE,gCAAwB,EAAEJ,KAAM,CAAC,IACjCR,YAAY,CAAEO,QAAS,CAAC,KAAK,MAAM;IACpC,MAAMM,2BAA2B,GAChCN,QAAQ,IACR,CAAEJ,QAAQ,CAAC,CAAC;IACZ;IACA;IACAM,UAAU,KAAK,YAAY,IAC3BE,mBAAmB;IACpB,MAAMG,wBAAwB,GAC7B,CAAEV,sBAAsB,CAAC,CAAC,IAC1B,CAAEH,WAAW,CAAC,CAAC,CAACc,eAAe,IAC/B,CAAEF,2BAA2B,IAC7BH,gBAAgB,IAChB,CAAEC,mBAAmB;IAEtB,OAAO;MACNK,0BAA0B,EAAEH,2BAA2B;MACvDI,uBAAuB,EAAEH;IAC1B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_data","_useGetNumberOfBlocksBeforeCell","_store","_useSettings","_jsxRuntime","helpText","selfStretch","parentLayout","orientation","__","ChildLayoutControl","value","childLayout","onChange","isShownByDefault","panelId","type","parentType","default","defaultParentType","parentLayoutType","jsx","FlexControls","GridControls","flexSize","hasFlexValue","flexResetLabel","availableUnits","useSettings","units","useCustomUnits","resetFlex","undefined","useEffect","jsxs","__experimentalVStack","as","ToolsPanelItem","spacing","hasValue","label","onDeselect","children","__experimentalToggleGroupControl","__nextHasNoMarginBottom","size","childLayoutOrientation","help","newFlexSize","isBlock","__experimentalToggleGroupControlOption","_x","__experimentalUnitControl","hideLabelFromVision","columnStart","rowStart","columnSpan","rowSpan","columnCount","rowCount","rootClientId","useSelect","select","blockEditorStore","getBlockRootClientId","moveBlocksToPosition","__unstableMarkNextChangeAsNotPersistent","useDispatch","getNumberOfBlocksBeforeCell","useGetNumberOfBlocksBeforeCell","hasStartValue","hasSpanValue","resetGridStarts","resetGridSpans","Fragment","__experimentalHStack","__experimentalInputControl","newColumnSpan","parseInt","min","newRowSpan","window","__experimentalEnableGridInteractivity","Flex","FlexItem","style","width","newColumnStart","max","newRowStart"],"sources":["@wordpress/block-editor/src/components/child-layout-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalInputControl as InputControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks-before-cell';\nimport { store as blockEditorStore } from '../../store';\nimport { useSettings } from '../use-settings';\n\nfunction helpText( selfStretch, parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\tif ( selfStretch === 'fill' ) {\n\t\treturn __( 'Stretch to fill available space.' );\n\t}\n\tif ( selfStretch === 'fixed' && orientation === 'horizontal' ) {\n\t\treturn __( 'Specify a fixed width.' );\n\t} else if ( selfStretch === 'fixed' ) {\n\t\treturn __( 'Specify a fixed height.' );\n\t}\n\treturn __( 'Fit contents.' );\n}\n\n/**\n * Form to edit the child layout value.\n *\n * @param {Object} props Props.\n * @param {Object} props.value The child layout value.\n * @param {Function} props.onChange Function to update the child layout value.\n * @param {Object} props.parentLayout The parent layout value.\n *\n * @param {boolean} props.isShownByDefault\n * @param {string} props.panelId\n * @return {Element} child layout edit element.\n */\nexport default function ChildLayoutControl( {\n\tvalue: childLayout = {},\n\tonChange,\n\tparentLayout,\n\tisShownByDefault,\n\tpanelId,\n} ) {\n\tconst {\n\t\ttype: parentType,\n\t\tdefault: { type: defaultParentType = 'default' } = {},\n\t} = parentLayout ?? {};\n\tconst parentLayoutType = parentType || defaultParentType;\n\n\tif ( parentLayoutType === 'flex' ) {\n\t\treturn (\n\t\t\t<FlexControls\n\t\t\t\tchildLayout={ childLayout }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\tpanelId={ panelId }\n\t\t\t/>\n\t\t);\n\t} else if ( parentLayoutType === 'grid' ) {\n\t\treturn (\n\t\t\t<GridControls\n\t\t\t\tchildLayout={ childLayout }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\tpanelId={ panelId }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nfunction FlexControls( {\n\tchildLayout,\n\tonChange,\n\tparentLayout,\n\tisShownByDefault,\n\tpanelId,\n} ) {\n\tconst { selfStretch, flexSize } = childLayout;\n\tconst { orientation = 'horizontal' } = parentLayout ?? {};\n\tconst hasFlexValue = () => !! selfStretch;\n\tconst flexResetLabel =\n\t\torientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst resetFlex = () => {\n\t\tonChange( {\n\t\t\tselfStretch: undefined,\n\t\t\tflexSize: undefined,\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( selfStretch === 'fixed' && ! flexSize ) {\n\t\t\tonChange( {\n\t\t\t\t...childLayout,\n\t\t\t\tselfStretch: 'fit',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<VStack\n\t\t\tas={ ToolsPanelItem }\n\t\t\tspacing={ 2 }\n\t\t\thasValue={ hasFlexValue }\n\t\t\tlabel={ flexResetLabel }\n\t\t\tonDeselect={ resetFlex }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\tlabel={ childLayoutOrientation( parentLayout ) }\n\t\t\t\tvalue={ selfStretch || 'fit' }\n\t\t\t\thelp={ helpText( selfStretch, parentLayout ) }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tconst newFlexSize = value !== 'fixed' ? null : flexSize;\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tselfStretch: value,\n\t\t\t\t\t\tflexSize: newFlexSize,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tisBlock\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey=\"fit\"\n\t\t\t\t\tvalue=\"fit\"\n\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t'Fit',\n\t\t\t\t\t\t'Intrinsic block width in flex layout'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey=\"fill\"\n\t\t\t\t\tvalue=\"fill\"\n\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t'Grow',\n\t\t\t\t\t\t'Block with expanding width in flex layout'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey=\"fixed\"\n\t\t\t\t\tvalue=\"fixed\"\n\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t'Fixed',\n\t\t\t\t\t\t'Block with fixed width in flex layout'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ selfStretch === 'fixed' && (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\tselfStretch,\n\t\t\t\t\t\t\tflexSize: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ flexSize }\n\t\t\t\t\tlabel={ flexResetLabel }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport function childLayoutOrientation( parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\treturn orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n}\n\nfunction GridControls( {\n\tchildLayout,\n\tonChange,\n\tparentLayout,\n\tisShownByDefault,\n\tpanelId,\n} ) {\n\tconst { columnStart, rowStart, columnSpan, rowSpan } = childLayout;\n\tconst { columnCount = 3, rowCount } = parentLayout ?? {};\n\tconst rootClientId = useSelect( ( select ) =>\n\t\tselect( blockEditorStore ).getBlockRootClientId( panelId )\n\t);\n\tconst { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(\n\t\trootClientId,\n\t\tcolumnCount\n\t);\n\tconst hasStartValue = () => !! columnStart || !! rowStart;\n\tconst hasSpanValue = () => !! columnSpan || !! rowSpan;\n\tconst resetGridStarts = () => {\n\t\tonChange( {\n\t\t\tcolumnStart: undefined,\n\t\t\trowStart: undefined,\n\t\t} );\n\t};\n\tconst resetGridSpans = () => {\n\t\tonChange( {\n\t\t\tcolumnSpan: undefined,\n\t\t\trowSpan: undefined,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<HStack\n\t\t\t\tas={ ToolsPanelItem }\n\t\t\t\thasValue={ hasSpanValue }\n\t\t\t\tlabel={ __( 'Grid span' ) }\n\t\t\t\tonDeselect={ resetGridSpans }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\tpanelId={ panelId }\n\t\t\t>\n\t\t\t\t<InputControl\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tlabel={ __( 'Column span' ) }\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\tconst newColumnSpan =\n\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\trowStart,\n\t\t\t\t\t\t\trowSpan,\n\t\t\t\t\t\t\tcolumnSpan: newColumnSpan,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ columnSpan ?? 1 }\n\t\t\t\t\tmin={ 1 }\n\t\t\t\t/>\n\t\t\t\t<InputControl\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tlabel={ __( 'Row span' ) }\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\tconst newRowSpan =\n\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\trowStart,\n\t\t\t\t\t\t\tcolumnSpan,\n\t\t\t\t\t\t\trowSpan: newRowSpan,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ rowSpan ?? 1 }\n\t\t\t\t\tmin={ 1 }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t\t{ window.__experimentalEnableGridInteractivity && columnCount && (\n\t\t\t\t// Use Flex with an explicit width on the FlexItem instead of HStack to\n\t\t\t\t// work around an issue in webkit where inputs with a max attribute are\n\t\t\t\t// sized incorrectly.\n\t\t\t\t<Flex\n\t\t\t\t\tas={ ToolsPanelItem }\n\t\t\t\t\thasValue={ hasStartValue }\n\t\t\t\t\tlabel={ __( 'Grid placement' ) }\n\t\t\t\t\tonDeselect={ resetGridStarts }\n\t\t\t\t\tisShownByDefault={ false }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem style={ { width: '50%' } }>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tlabel={ __( 'Column' ) }\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\t\t\tconst newColumnStart =\n\t\t\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\tcolumnStart: newColumnStart,\n\t\t\t\t\t\t\t\t\trowStart,\n\t\t\t\t\t\t\t\t\tcolumnSpan,\n\t\t\t\t\t\t\t\t\trowSpan,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t\t\t\t[ panelId ],\n\t\t\t\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\t\t\t\tnewColumnStart,\n\t\t\t\t\t\t\t\t\t\trowStart\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\tvalue={ columnStart ?? 1 }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\tcolumnCount\n\t\t\t\t\t\t\t\t\t? columnCount - ( columnSpan ?? 1 ) + 1\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem style={ { width: '50%' } }>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tlabel={ __( 'Row' ) }\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\t\t\tconst newRowStart =\n\t\t\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\t\t\trowStart: newRowStart,\n\t\t\t\t\t\t\t\t\tcolumnSpan,\n\t\t\t\t\t\t\t\t\trowSpan,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t\t\t\t[ panelId ],\n\t\t\t\t\t\t\t\t\trootClientId,\n\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AC,CACO,CAAC;IAAA,CACN,CACN;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_data","_useGetNumberOfBlocksBeforeCell","_store","_useSettings","_jsxRuntime","helpText","selfStretch","parentLayout","orientation","__","ChildLayoutControl","value","childLayout","onChange","isShownByDefault","panelId","type","parentType","default","defaultParentType","parentLayoutType","jsx","FlexControls","GridControls","flexSize","hasFlexValue","flexResetLabel","availableUnits","useSettings","units","useCustomUnits","resetFlex","undefined","useEffect","jsxs","__experimentalVStack","as","ToolsPanelItem","spacing","hasValue","label","onDeselect","children","__experimentalToggleGroupControl","__nextHasNoMarginBottom","size","childLayoutOrientation","help","newFlexSize","isBlock","__experimentalToggleGroupControlOption","_x","__experimentalUnitControl","min","hideLabelFromVision","columnStart","rowStart","columnSpan","rowSpan","columnCount","rowCount","rootClientId","useSelect","select","blockEditorStore","getBlockRootClientId","moveBlocksToPosition","__unstableMarkNextChangeAsNotPersistent","useDispatch","getNumberOfBlocksBeforeCell","useGetNumberOfBlocksBeforeCell","hasStartValue","hasSpanValue","resetGridStarts","resetGridSpans","Fragment","__experimentalHStack","__experimentalInputControl","newColumnSpan","parseInt","newRowSpan","window","__experimentalEnableGridInteractivity","Flex","FlexItem","style","width","newColumnStart","max","newRowStart"],"sources":["@wordpress/block-editor/src/components/child-layout-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalInputControl as InputControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks-before-cell';\nimport { store as blockEditorStore } from '../../store';\nimport { useSettings } from '../use-settings';\n\nfunction helpText( selfStretch, parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\tif ( selfStretch === 'fill' ) {\n\t\treturn __( 'Stretch to fill available space.' );\n\t}\n\tif ( selfStretch === 'fixed' && orientation === 'horizontal' ) {\n\t\treturn __( 'Specify a fixed width.' );\n\t} else if ( selfStretch === 'fixed' ) {\n\t\treturn __( 'Specify a fixed height.' );\n\t}\n\treturn __( 'Fit contents.' );\n}\n\n/**\n * Form to edit the child layout value.\n *\n * @param {Object} props Props.\n * @param {Object} props.value The child layout value.\n * @param {Function} props.onChange Function to update the child layout value.\n * @param {Object} props.parentLayout The parent layout value.\n *\n * @param {boolean} props.isShownByDefault\n * @param {string} props.panelId\n * @return {Element} child layout edit element.\n */\nexport default function ChildLayoutControl( {\n\tvalue: childLayout = {},\n\tonChange,\n\tparentLayout,\n\tisShownByDefault,\n\tpanelId,\n} ) {\n\tconst {\n\t\ttype: parentType,\n\t\tdefault: { type: defaultParentType = 'default' } = {},\n\t} = parentLayout ?? {};\n\tconst parentLayoutType = parentType || defaultParentType;\n\n\tif ( parentLayoutType === 'flex' ) {\n\t\treturn (\n\t\t\t<FlexControls\n\t\t\t\tchildLayout={ childLayout }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\tpanelId={ panelId }\n\t\t\t/>\n\t\t);\n\t} else if ( parentLayoutType === 'grid' ) {\n\t\treturn (\n\t\t\t<GridControls\n\t\t\t\tchildLayout={ childLayout }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\tpanelId={ panelId }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nfunction FlexControls( {\n\tchildLayout,\n\tonChange,\n\tparentLayout,\n\tisShownByDefault,\n\tpanelId,\n} ) {\n\tconst { selfStretch, flexSize } = childLayout;\n\tconst { orientation = 'horizontal' } = parentLayout ?? {};\n\tconst hasFlexValue = () => !! selfStretch;\n\tconst flexResetLabel =\n\t\torientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst resetFlex = () => {\n\t\tonChange( {\n\t\t\tselfStretch: undefined,\n\t\t\tflexSize: undefined,\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( selfStretch === 'fixed' && ! flexSize ) {\n\t\t\tonChange( {\n\t\t\t\t...childLayout,\n\t\t\t\tselfStretch: 'fit',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<VStack\n\t\t\tas={ ToolsPanelItem }\n\t\t\tspacing={ 2 }\n\t\t\thasValue={ hasFlexValue }\n\t\t\tlabel={ flexResetLabel }\n\t\t\tonDeselect={ resetFlex }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\tlabel={ childLayoutOrientation( parentLayout ) }\n\t\t\t\tvalue={ selfStretch || 'fit' }\n\t\t\t\thelp={ helpText( selfStretch, parentLayout ) }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tconst newFlexSize = value !== 'fixed' ? null : flexSize;\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tselfStretch: value,\n\t\t\t\t\t\tflexSize: newFlexSize,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tisBlock\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey=\"fit\"\n\t\t\t\t\tvalue=\"fit\"\n\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t'Fit',\n\t\t\t\t\t\t'Intrinsic block width in flex layout'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey=\"fill\"\n\t\t\t\t\tvalue=\"fill\"\n\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t'Grow',\n\t\t\t\t\t\t'Block with expanding width in flex layout'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey=\"fixed\"\n\t\t\t\t\tvalue=\"fixed\"\n\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t'Fixed',\n\t\t\t\t\t\t'Block with fixed width in flex layout'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ selfStretch === 'fixed' && (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\tselfStretch,\n\t\t\t\t\t\t\tflexSize: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ flexSize }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tlabel={ flexResetLabel }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport function childLayoutOrientation( parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\treturn orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n}\n\nfunction GridControls( {\n\tchildLayout,\n\tonChange,\n\tparentLayout,\n\tisShownByDefault,\n\tpanelId,\n} ) {\n\tconst { columnStart, rowStart, columnSpan, rowSpan } = childLayout;\n\tconst { columnCount = 3, rowCount } = parentLayout ?? {};\n\tconst rootClientId = useSelect( ( select ) =>\n\t\tselect( blockEditorStore ).getBlockRootClientId( panelId )\n\t);\n\tconst { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(\n\t\trootClientId,\n\t\tcolumnCount\n\t);\n\tconst hasStartValue = () => !! columnStart || !! rowStart;\n\tconst hasSpanValue = () => !! columnSpan || !! rowSpan;\n\tconst resetGridStarts = () => {\n\t\tonChange( {\n\t\t\tcolumnStart: undefined,\n\t\t\trowStart: undefined,\n\t\t} );\n\t};\n\tconst resetGridSpans = () => {\n\t\tonChange( {\n\t\t\tcolumnSpan: undefined,\n\t\t\trowSpan: undefined,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<HStack\n\t\t\t\tas={ ToolsPanelItem }\n\t\t\t\thasValue={ hasSpanValue }\n\t\t\t\tlabel={ __( 'Grid span' ) }\n\t\t\t\tonDeselect={ resetGridSpans }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\tpanelId={ panelId }\n\t\t\t>\n\t\t\t\t<InputControl\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tlabel={ __( 'Column span' ) }\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\tconst newColumnSpan =\n\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\trowStart,\n\t\t\t\t\t\t\trowSpan,\n\t\t\t\t\t\t\tcolumnSpan: newColumnSpan,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ columnSpan ?? 1 }\n\t\t\t\t\tmin={ 1 }\n\t\t\t\t/>\n\t\t\t\t<InputControl\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tlabel={ __( 'Row span' ) }\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\tconst newRowSpan =\n\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\trowStart,\n\t\t\t\t\t\t\tcolumnSpan,\n\t\t\t\t\t\t\trowSpan: newRowSpan,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ rowSpan ?? 1 }\n\t\t\t\t\tmin={ 1 }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t\t{ window.__experimentalEnableGridInteractivity && columnCount && (\n\t\t\t\t// Use Flex with an explicit width on the FlexItem instead of HStack to\n\t\t\t\t// work around an issue in webkit where inputs with a max attribute are\n\t\t\t\t// sized incorrectly.\n\t\t\t\t<Flex\n\t\t\t\t\tas={ ToolsPanelItem }\n\t\t\t\t\thasValue={ hasStartValue }\n\t\t\t\t\tlabel={ __( 'Grid placement' ) }\n\t\t\t\t\tonDeselect={ resetGridStarts }\n\t\t\t\t\tisShownByDefault={ false }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem style={ { width: '50%' } }>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tlabel={ __( 'Column' ) }\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\t\t\tconst newColumnStart =\n\t\t\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\tcolumnStart: newColumnStart,\n\t\t\t\t\t\t\t\t\trowStart,\n\t\t\t\t\t\t\t\t\tcolumnSpan,\n\t\t\t\t\t\t\t\t\trowSpan,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t\t\t\t[ panelId ],\n\t\t\t\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\t\t\t\tnewColumnStart,\n\t\t\t\t\t\t\t\t\t\trowStart\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\tvalue={ columnStart ?? 1 }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\tcolumnCount\n\t\t\t\t\t\t\t\t\t? columnCount - ( columnSpan ?? 1 ) + 1\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem style={ { width: '50%' } }>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tlabel={ __( 'Row' ) }\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t// Don't allow unsetting.\n\t\t\t\t\t\t\t\tconst newRowStart =\n\t\t\t\t\t\t\t\t\tvalue === '' ? 1 : parseInt( value, 10 );\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\t\t\trowStart: newRowStart,\n\t\t\t\t\t\t\t\t\tcolumnSpan,\n\t\t\t\t\t\t\t\t\trowSpan,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t\t\t\t[ panelId ],\n\t\t\t\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\t\t\t\tcolumnStart,\n\t\t\t\t\t\t\t\t\t\tnewRowStart\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\tvalue={ rowStart ?? 1 }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\trowCount\n\t\t\t\t\t\t\t\t\t? rowCount - ( rowSpan ?? 1 ) + 1\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAYA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,+BAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAA8C,IAAAO,WAAA,GAAAP,OAAA;AAxB9C;AACA;AACA;;AAiBA;AACA;AACA;;AAKA,SAASQ,QAAQA,CAAEC,WAAW,EAAEC,YAAY,EAAG;EAC9C,MAAM;IAAEC,WAAW,GAAG;EAAa,CAAC,GAAGD,YAAY;EAEnD,IAAKD,WAAW,KAAK,MAAM,EAAG;IAC7B,OAAO,IAAAG,QAAE,EAAE,kCAAmC,CAAC;EAChD;EACA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,EAAG6C,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,CAAG;UACvBH,GAAG,EAAG,CAAG;UACTmC,GAAG,EACF5B,QAAQ,GACLA,QAAQ,IAAKF,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,CAAC,CAAE,GAAG,CAAC,GAC/B1B;QACH,CACD;MAAC,CACO,CAAC;IAAA,CACN,CACN;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = HTMLElementControl;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
var _components = require("@wordpress/components");
|
|
9
|
+
var _data = require("@wordpress/data");
|
|
10
|
+
var _store = require("../../store");
|
|
11
|
+
var _messages = require("./messages");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Renders a SelectControl for choosing HTML elements with validation
|
|
23
|
+
* to prevent duplicate <main> elements.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} props Component props.
|
|
26
|
+
* @param {string} props.tagName The current HTML tag name.
|
|
27
|
+
* @param {Function} props.onChange Function to call when the tag is changed.
|
|
28
|
+
* @param {string} props.clientId The client ID of the current block.
|
|
29
|
+
* @param {Array} props.options SelectControl options (optional).
|
|
30
|
+
*
|
|
31
|
+
* @return {Component} The HTML element select control with validation.
|
|
32
|
+
*/function HTMLElementControl({
|
|
33
|
+
tagName,
|
|
34
|
+
onChange,
|
|
35
|
+
clientId,
|
|
36
|
+
options = [{
|
|
37
|
+
label: (0, _i18n.__)('Default (<div>)'),
|
|
38
|
+
value: 'div'
|
|
39
|
+
}, {
|
|
40
|
+
label: '<header>',
|
|
41
|
+
value: 'header'
|
|
42
|
+
}, {
|
|
43
|
+
label: '<main>',
|
|
44
|
+
value: 'main'
|
|
45
|
+
}, {
|
|
46
|
+
label: '<section>',
|
|
47
|
+
value: 'section'
|
|
48
|
+
}, {
|
|
49
|
+
label: '<article>',
|
|
50
|
+
value: 'article'
|
|
51
|
+
}, {
|
|
52
|
+
label: '<aside>',
|
|
53
|
+
value: 'aside'
|
|
54
|
+
}, {
|
|
55
|
+
label: '<footer>',
|
|
56
|
+
value: 'footer'
|
|
57
|
+
}]
|
|
58
|
+
}) {
|
|
59
|
+
const checkForMainTag = !!clientId && options.some(option => option.value === 'main');
|
|
60
|
+
const hasMainElementElsewhere = (0, _data.useSelect)(select => {
|
|
61
|
+
if (!checkForMainTag) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const {
|
|
65
|
+
getClientIdsWithDescendants,
|
|
66
|
+
getBlockAttributes
|
|
67
|
+
} = select(_store.store);
|
|
68
|
+
return getClientIdsWithDescendants().some(id => {
|
|
69
|
+
// Skip the current block.
|
|
70
|
+
if (id === clientId) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return getBlockAttributes(id)?.tagName === 'main';
|
|
74
|
+
});
|
|
75
|
+
}, [clientId, checkForMainTag]);
|
|
76
|
+
|
|
77
|
+
// Create a modified options array that disables the main option if needed.
|
|
78
|
+
const modifiedOptions = options.map(option => {
|
|
79
|
+
if (option.value === 'main' && hasMainElementElsewhere && tagName !== 'main') {
|
|
80
|
+
return {
|
|
81
|
+
...option,
|
|
82
|
+
disabled: true,
|
|
83
|
+
label: (0, _i18n.sprintf)(/* translators: %s: HTML element name */
|
|
84
|
+
(0, _i18n.__)('%s (Already in use)'), option.label)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return option;
|
|
88
|
+
});
|
|
89
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
90
|
+
spacing: 2,
|
|
91
|
+
className: "block-editor-html-element-control",
|
|
92
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
|
|
93
|
+
__nextHasNoMarginBottom: true,
|
|
94
|
+
__next40pxDefaultSize: true,
|
|
95
|
+
label: (0, _i18n.__)('HTML element'),
|
|
96
|
+
options: modifiedOptions,
|
|
97
|
+
value: tagName,
|
|
98
|
+
onChange: onChange,
|
|
99
|
+
help: _messages.htmlElementMessages[tagName]
|
|
100
|
+
}), tagName === 'main' && hasMainElementElsewhere && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Notice, {
|
|
101
|
+
status: "warning",
|
|
102
|
+
isDismissible: false,
|
|
103
|
+
children: (0, _i18n.__)('Multiple <main> elements detected. The duplicate may be in your content or template. This is not valid HTML and may cause accessibility issues. Please change this HTML element.')
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_store","_messages","_jsxRuntime","HTMLElementControl","tagName","onChange","clientId","options","label","__","value","checkForMainTag","some","option","hasMainElementElsewhere","useSelect","select","getClientIdsWithDescendants","getBlockAttributes","blockEditorStore","id","modifiedOptions","map","disabled","sprintf","jsxs","__experimentalVStack","spacing","className","children","jsx","SelectControl","__nextHasNoMarginBottom","__next40pxDefaultSize","help","htmlElementMessages","Notice","status","isDismissible"],"sources":["@wordpress/block-editor/src/components/html-element-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tSelectControl,\n\tNotice,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { htmlElementMessages } from './messages';\n\n/**\n * Renders a SelectControl for choosing HTML elements with validation\n * to prevent duplicate <main> elements.\n *\n * @param {Object} props Component props.\n * @param {string} props.tagName The current HTML tag name.\n * @param {Function} props.onChange Function to call when the tag is changed.\n * @param {string} props.clientId The client ID of the current block.\n * @param {Array} props.options SelectControl options (optional).\n *\n * @return {Component} The HTML element select control with validation.\n */\nexport default function HTMLElementControl( {\n\ttagName,\n\tonChange,\n\tclientId,\n\toptions = [\n\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t{ label: '<header>', value: 'header' },\n\t\t{ label: '<main>', value: 'main' },\n\t\t{ label: '<section>', value: 'section' },\n\t\t{ label: '<article>', value: 'article' },\n\t\t{ label: '<aside>', value: 'aside' },\n\t\t{ label: '<footer>', value: 'footer' },\n\t],\n} ) {\n\tconst checkForMainTag =\n\t\t!! clientId && options.some( ( option ) => option.value === 'main' );\n\n\tconst hasMainElementElsewhere = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! checkForMainTag ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst { getClientIdsWithDescendants, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsWithDescendants().some( ( id ) => {\n\t\t\t\t// Skip the current block.\n\t\t\t\tif ( id === clientId ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn getBlockAttributes( id )?.tagName === 'main';\n\t\t\t} );\n\t\t},\n\t\t[ clientId, checkForMainTag ]\n\t);\n\n\t// Create a modified options array that disables the main option if needed.\n\tconst modifiedOptions = options.map( ( option ) => {\n\t\tif (\n\t\t\toption.value === 'main' &&\n\t\t\thasMainElementElsewhere &&\n\t\t\ttagName !== 'main'\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...option,\n\t\t\t\tdisabled: true,\n\t\t\t\tlabel: sprintf(\n\t\t\t\t\t/* translators: %s: HTML element name */\n\t\t\t\t\t__( '%s (Already in use)' ),\n\t\t\t\t\toption.label\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t\treturn option;\n\t} );\n\n\treturn (\n\t\t<VStack spacing={ 2 } className=\"block-editor-html-element-control\">\n\t\t\t<SelectControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\toptions={ modifiedOptions }\n\t\t\t\tvalue={ tagName }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t/>\n\n\t\t\t{ tagName === 'main' && hasMainElementElsewhere && (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Multiple <main> elements detected. The duplicate may be in your content or template. This is not valid HTML and may cause accessibility issues. Please change this HTML element.'\n\t\t\t\t\t) }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAiD,IAAAK,WAAA,GAAAL,OAAA;AAfjD;AACA;AACA;;AASA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,SAASM,kBAAkBA,CAAE;EAC3CC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,OAAO,GAAG,CACT;IAAEC,KAAK,EAAE,IAAAC,QAAE,EAAE,iBAAkB,CAAC;IAAEC,KAAK,EAAE;EAAM,CAAC,EAChD;IAAEF,KAAK,EAAE,UAAU;IAAEE,KAAK,EAAE;EAAS,CAAC,EACtC;IAAEF,KAAK,EAAE,QAAQ;IAAEE,KAAK,EAAE;EAAO,CAAC,EAClC;IAAEF,KAAK,EAAE,WAAW;IAAEE,KAAK,EAAE;EAAU,CAAC,EACxC;IAAEF,KAAK,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EAAG,CAAG;IAACC,SAAS,EAAC,mCAAmC;IAAAC,QAAA,gBAClE,IAAA3B,WAAA,CAAA4B,GAAA,EAAChC,WAAA,CAAAiC,aAAa;MACbC,uBAAuB;MACvBC,qBAAqB;MACrBzB,KAAK,EAAG,IAAAC,QAAE,EAAE,cAAe,CAAG;MAC9BF,OAAO,EAAGc,eAAiB;MAC3BX,KAAK,EAAGN,OAAS;MACjBC,QAAQ,EAAGA,QAAU;MACrB6B,IAAI,EAAGC,6BAAmB,CAAE/B,OAAO;IAAI,CACvC,CAAC,EAEAA,OAAO,KAAK,MAAM,IAAIU,uBAAuB,iBAC9C,IAAAZ,WAAA,CAAA4B,GAAA,EAAChC,WAAA,CAAAsC,MAAM;MAACC,MAAM,EAAC,SAAS;MAACC,aAAa,EAAG,KAAO;MAAAT,QAAA,EAC7C,IAAApB,QAAE,EACH,kLACD;IAAC,CACM,CACR;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.htmlElementMessages = void 0;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Messages providing helpful descriptions for HTML elements.
|
|
14
|
+
*/
|
|
15
|
+
const htmlElementMessages = exports.htmlElementMessages = {
|
|
16
|
+
article: (0, _i18n.__)('The <article> element should represent a self-contained, syndicatable portion of the document.'),
|
|
17
|
+
aside: (0, _i18n.__)("The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."),
|
|
18
|
+
div: (0, _i18n.__)('The <div> element should only be used if the block is a design element with no semantic meaning.'),
|
|
19
|
+
footer: (0, _i18n.__)('The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'),
|
|
20
|
+
header: (0, _i18n.__)('The <header> element should represent introductory content, typically a group of introductory or navigational aids.'),
|
|
21
|
+
main: (0, _i18n.__)('The <main> element should be used for the primary content of your document only.'),
|
|
22
|
+
nav: (0, _i18n.__)('The <nav> element should be used to identify groups of links that are intended to be used for website or page content navigation.'),
|
|
23
|
+
section: (0, _i18n.__)("The <section> element should represent a standalone portion of the document that can't be better represented by another element.")
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","htmlElementMessages","exports","article","__","aside","div","footer","header","main","nav","section"],"sources":["@wordpress/block-editor/src/components/html-element-control/messages.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Messages providing helpful descriptions for HTML elements.\n */\nexport const htmlElementMessages = {\n\tarticle: __(\n\t\t'The <article> element should represent a self-contained, syndicatable portion of the document.'\n\t),\n\taside: __(\n\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t),\n\tdiv: __(\n\t\t'The <div> element should only be used if the block is a design element with no semantic meaning.'\n\t),\n\tfooter: __(\n\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t),\n\theader: __(\n\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t),\n\tmain: __(\n\t\t'The <main> element should be used for the primary content of your document only.'\n\t),\n\tnav: __(\n\t\t'The <nav> element should be used to identify groups of links that are intended to be used for website or page content navigation.'\n\t),\n\tsection: __(\n\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t),\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EAClCE,OAAO,EAAE,IAAAC,QAAE,EACV,gGACD,CAAC;EACDC,KAAK,EAAE,IAAAD,QAAE,EACR,uIACD,CAAC;EACDE,GAAG,EAAE,IAAAF,QAAE,EACN,kGACD,CAAC;EACDG,MAAM,EAAE,IAAAH,QAAE,EACT,8HACD,CAAC;EACDI,MAAM,EAAE,IAAAJ,QAAE,EACT,qHACD,CAAC;EACDK,IAAI,EAAE,IAAAL,QAAE,EACP,kFACD,CAAC;EACDM,GAAG,EAAE,IAAAN,QAAE,EACN,mIACD,CAAC;EACDO,OAAO,EAAE,IAAAP,QAAE,EACV,kIACD;AACD,CAAC","ignoreList":[]}
|
|
@@ -32,7 +32,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
const ALLOWED_MEDIA_TYPES = ['image'];
|
|
35
|
-
const MAXIMUM_TITLE_LENGTH = 25;
|
|
36
35
|
const MEDIA_OPTIONS_POPOVER_PROPS = {
|
|
37
36
|
position: 'bottom left',
|
|
38
37
|
className: 'block-editor-inserter__media-list__item-preview-options__popover'
|
|
@@ -200,11 +199,6 @@ function MediaPreview({
|
|
|
200
199
|
});
|
|
201
200
|
}, [isInserting, getSettings, onClick, createSuccessNotice, updateBlockAttributes, createErrorNotice, getBlock]);
|
|
202
201
|
const title = typeof media.title === 'string' ? media.title : media.title?.rendered || (0, _i18n.__)('no title');
|
|
203
|
-
let truncatedTitle;
|
|
204
|
-
if (title.length > MAXIMUM_TITLE_LENGTH) {
|
|
205
|
-
const omission = '...';
|
|
206
|
-
truncatedTitle = title.slice(0, MAXIMUM_TITLE_LENGTH - omission.length) + omission;
|
|
207
|
-
}
|
|
208
202
|
const onMouseEnter = (0, _element.useCallback)(() => setIsHovered(true), []);
|
|
209
203
|
const onMouseLeave = (0, _element.useCallback)(() => setIsHovered(false), []);
|
|
210
204
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -226,7 +220,7 @@ function MediaPreview({
|
|
|
226
220
|
onMouseEnter: onMouseEnter,
|
|
227
221
|
onMouseLeave: onMouseLeave,
|
|
228
222
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
229
|
-
text:
|
|
223
|
+
text: title,
|
|
230
224
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Composite.Item, {
|
|
231
225
|
render: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
232
226
|
"aria-label": title,
|