@wordpress/block-editor 15.18.0 → 15.19.1-next.v.202605131006.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 +6 -0
- package/build/components/block-controls/fill.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +7 -1
- package/build/components/block-inspector/edit-contents.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs +7 -1
- package/build/components/block-toolbar/edit-section-button.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +2 -2
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +0 -10
- package/build/components/block-visibility/modal.cjs.map +3 -3
- package/build/components/dimensions-tool/scale-tool.cjs +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +111 -37
- package/build/components/global-styles/state-control.cjs.map +3 -3
- package/build/components/gradients/use-gradient.cjs +2 -2
- package/build/components/gradients/use-gradient.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inserter/index.cjs +41 -43
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +30 -2
- package/build/components/inserter/menu.cjs.map +3 -3
- package/build/components/inserter/tips.cjs +1 -1
- package/build/components/inserter/tips.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +2 -2
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/reducer.cjs +8 -30
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-controls/fill.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +7 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs +7 -1
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +2 -2
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +0 -10
- package/build-module/components/block-visibility/modal.mjs.map +3 -3
- package/build-module/components/dimensions-tool/scale-tool.mjs +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +119 -40
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/gradients/use-gradient.mjs +2 -2
- package/build-module/components/gradients/use-gradient.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +41 -43
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +31 -2
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/tips.mjs +1 -1
- package/build-module/components/inserter/tips.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
- package/build-module/store/actions.mjs +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +8 -30
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +29 -3
- package/build-style/style.css +29 -3
- package/build-types/components/block-context/index.d.ts +9 -16
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts +7 -7
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +39 -39
- package/src/components/block-controls/fill.js +1 -0
- package/src/components/block-inspector/edit-contents.js +4 -2
- package/src/components/block-manager/style.scss +3 -2
- package/src/components/block-toolbar/edit-section-button.js +5 -1
- package/src/components/block-variation-transforms/index.js +2 -2
- package/src/components/block-visibility/modal.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +2 -2
- package/src/components/global-styles/state-control.js +152 -49
- package/src/components/global-styles/style.scss +9 -0
- package/src/components/gradients/use-gradient.js +3 -1
- package/src/components/iframe/use-scale-canvas.js +0 -4
- package/src/components/inner-blocks/README.md +5 -1
- package/src/components/inner-blocks/index.native.js +1 -1
- package/src/components/inserter/index.js +58 -69
- package/src/components/inserter/menu.js +32 -1
- package/src/components/inserter/style.scss +18 -3
- package/src/components/inserter/tips.js +1 -1
- package/src/components/rich-text/event-listeners/index.js +0 -1
- package/src/store/actions.js +12 -6
- package/src/store/reducer.js +11 -39
- package/src/store/selectors.js +6 -0
- package/src/store/test/reducer.js +39 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/gradients/use-gradient.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { useSettings } from '../use-settings';\nimport { store as blockEditorStore } from '../../store';\n\nexport function __experimentalGetGradientClass( gradientSlug ) {\n\tif ( ! gradientSlug ) {\n\t\treturn undefined;\n\t}\n\treturn `has-${ gradientSlug }-gradient-background`;\n}\n\n/**\n * Retrieves the gradient value per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} slug Gradient slug\n *\n * @return {string} Gradient value.\n */\nexport function getGradientValueBySlug( gradients, slug ) {\n\tconst gradient = gradients?.find( ( g ) => g.slug === slug );\n\treturn gradient && gradient.gradient;\n}\n\nexport function __experimentalGetGradientObjectByGradientValue(\n\tgradients,\n\tvalue\n) {\n\tconst gradient = gradients?.find( ( g ) => g.gradient === value );\n\treturn gradient;\n}\n\n/**\n * Retrieves the gradient slug per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} value Gradient value\n * @return {string} Gradient slug.\n */\nexport function getGradientSlugByValue( gradients, value ) {\n\tconst gradient = __experimentalGetGradientObjectByGradientValue(\n\t\tgradients,\n\t\tvalue\n\t);\n\treturn gradient && gradient.slug;\n}\n\
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,eAAe;AACrC,SAAS,WAAW,mBAAmB;AAKvC,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAEnC,SAAS,+BAAgC,cAAe;AAC9D,MAAK,CAAE,cAAe;AACrB,WAAO;AAAA,EACR;AACA,SAAO,OAAQ,YAAa;AAC7B;AAUO,SAAS,uBAAwB,WAAW,MAAO;AACzD,QAAM,WAAW,WAAW,KAAM,CAAE,MAAO,EAAE,SAAS,IAAK;AAC3D,SAAO,YAAY,SAAS;AAC7B;AAEO,SAAS,+CACf,WACA,OACC;AACD,QAAM,WAAW,WAAW,KAAM,CAAE,MAAO,EAAE,aAAa,KAAM;AAChE,SAAO;AACR;AASO,SAAS,uBAAwB,WAAW,OAAQ;AAC1D,QAAM,WAAW;AAAA,IAChB;AAAA,IACA;AAAA,EACD;AACA,SAAO,YAAY,SAAS;AAC7B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { useSettings } from '../use-settings';\nimport { store as blockEditorStore } from '../../store';\n\nexport function __experimentalGetGradientClass( gradientSlug ) {\n\tif ( ! gradientSlug ) {\n\t\treturn undefined;\n\t}\n\treturn `has-${ gradientSlug }-gradient-background`;\n}\n\n/**\n * Retrieves the gradient value per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} slug Gradient slug\n *\n * @return {string} Gradient value.\n */\nexport function getGradientValueBySlug( gradients, slug ) {\n\tconst gradient = gradients?.find( ( g ) => g.slug === slug );\n\treturn gradient && gradient.gradient;\n}\n\nexport function __experimentalGetGradientObjectByGradientValue(\n\tgradients,\n\tvalue\n) {\n\tconst gradient = gradients?.find( ( g ) => g.gradient === value );\n\treturn gradient;\n}\n\n/**\n * Retrieves the gradient slug per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} value Gradient value\n * @return {string} Gradient slug.\n */\nexport function getGradientSlugByValue( gradients, value ) {\n\tconst gradient = __experimentalGetGradientObjectByGradientValue(\n\t\tgradients,\n\t\tvalue\n\t);\n\treturn gradient && gradient.slug;\n}\n\nfunction useGradient( {\n\tgradientAttribute = 'gradient',\n\tcustomGradientAttribute = 'customGradient',\n} = {} ) {\n\tconst { clientId } = useBlockEditContext();\n\n\tconst [\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t] = useSettings(\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default'\n\t);\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( userGradientPalette || [] ),\n\t\t\t...( themeGradientPalette || [] ),\n\t\t\t...( defaultGradientPalette || [] ),\n\t\t],\n\t\t[ userGradientPalette, themeGradientPalette, defaultGradientPalette ]\n\t);\n\tconst { gradient, customGradient } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tcustomGradient: attributes[ customGradientAttribute ],\n\t\t\t\tgradient: attributes[ gradientAttribute ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, gradientAttribute, customGradientAttribute ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst setGradient = useCallback(\n\t\t( newGradientValue ) => {\n\t\t\tconst slug = getGradientSlugByValue(\n\t\t\t\tallGradients,\n\t\t\t\tnewGradientValue\n\t\t\t);\n\t\t\tif ( slug ) {\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t[ gradientAttribute ]: slug,\n\t\t\t\t\t[ customGradientAttribute ]: undefined,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t[ gradientAttribute ]: undefined,\n\t\t\t\t[ customGradientAttribute ]: newGradientValue,\n\t\t\t} );\n\t\t},\n\t\t[ allGradients, clientId, updateBlockAttributes ]\n\t);\n\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tlet gradientValue;\n\tif ( gradient ) {\n\t\tgradientValue = getGradientValueBySlug( allGradients, gradient );\n\t} else {\n\t\tgradientValue = customGradient;\n\t}\n\treturn { gradientClass, gradientValue, setGradient };\n}\n\nexport { useGradient as __experimentalUseGradient };\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,eAAe;AACrC,SAAS,WAAW,mBAAmB;AAKvC,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAEnC,SAAS,+BAAgC,cAAe;AAC9D,MAAK,CAAE,cAAe;AACrB,WAAO;AAAA,EACR;AACA,SAAO,OAAQ,YAAa;AAC7B;AAUO,SAAS,uBAAwB,WAAW,MAAO;AACzD,QAAM,WAAW,WAAW,KAAM,CAAE,MAAO,EAAE,SAAS,IAAK;AAC3D,SAAO,YAAY,SAAS;AAC7B;AAEO,SAAS,+CACf,WACA,OACC;AACD,QAAM,WAAW,WAAW,KAAM,CAAE,MAAO,EAAE,aAAa,KAAM;AAChE,SAAO;AACR;AASO,SAAS,uBAAwB,WAAW,OAAQ;AAC1D,QAAM,WAAW;AAAA,IAChB;AAAA,IACA;AAAA,EACD;AACA,SAAO,YAAY,SAAS;AAC7B;AAEA,SAAS,YAAa;AAAA,EACrB,oBAAoB;AAAA,EACpB,0BAA0B;AAC3B,IAAI,CAAC,GAAI;AACR,QAAM,EAAE,SAAS,IAAI,oBAAoB;AAEzC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,eAAe;AAAA,IACpB,MAAM;AAAA,MACL,GAAK,uBAAuB,CAAC;AAAA,MAC7B,GAAK,wBAAwB,CAAC;AAAA,MAC9B,GAAK,0BAA0B,CAAC;AAAA,IACjC;AAAA,IACA,CAAE,qBAAqB,sBAAsB,sBAAuB;AAAA,EACrE;AACA,QAAM,EAAE,UAAU,eAAe,IAAI;AAAA,IACpC,CAAE,WAAY;AACb,YAAM,EAAE,mBAAmB,IAAI,OAAQ,gBAAiB;AACxD,YAAM,aAAa,mBAAoB,QAAS,KAAK,CAAC;AACtD,aAAO;AAAA,QACN,gBAAgB,WAAY,uBAAwB;AAAA,QACpD,UAAU,WAAY,iBAAkB;AAAA,MACzC;AAAA,IACD;AAAA,IACA,CAAE,UAAU,mBAAmB,uBAAwB;AAAA,EACxD;AAEA,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAChE,QAAM,cAAc;AAAA,IACnB,CAAE,qBAAsB;AACvB,YAAM,OAAO;AAAA,QACZ;AAAA,QACA;AAAA,MACD;AACA,UAAK,MAAO;AACX,8BAAuB,UAAU;AAAA,UAChC,CAAE,iBAAkB,GAAG;AAAA,UACvB,CAAE,uBAAwB,GAAG;AAAA,QAC9B,CAAE;AACF;AAAA,MACD;AACA,4BAAuB,UAAU;AAAA,QAChC,CAAE,iBAAkB,GAAG;AAAA,QACvB,CAAE,uBAAwB,GAAG;AAAA,MAC9B,CAAE;AAAA,IACH;AAAA,IACA,CAAE,cAAc,UAAU,qBAAsB;AAAA,EACjD;AAEA,QAAM,gBAAgB,+BAAgC,QAAS;AAC/D,MAAI;AACJ,MAAK,UAAW;AACf,oBAAgB,uBAAwB,cAAc,QAAS;AAAA,EAChE,OAAO;AACN,oBAAgB;AAAA,EACjB;AACA,SAAO,EAAE,eAAe,eAAe,YAAY;AACpD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/iframe/use-scale-canvas.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\n\n/**\n * @typedef {Object} TransitionState\n * @property {number} scaleValue Scale of the canvas.\n * @property {number} frameSize Size of the frame/offset around the canvas.\n * @property {number} containerHeight containerHeight of the iframe.\n * @property {number} scrollTop ScrollTop of the iframe.\n * @property {number} scrollHeight ScrollHeight of the iframe.\n */\n\n/**\n * Calculate the scale of the canvas.\n *\n * @param {Object} options Object of options\n * @param {number} options.frameSize Size of the frame/offset around the canvas\n * @param {number} options.containerWidth Actual width of the canvas container\n * @param {number} options.maxContainerWidth Maximum width of the container to use for the scale calculation. This locks the canvas to a maximum width when zooming out.\n * @param {number} options.scaleContainerWidth Width the of the container wrapping the canvas container\n * @return {number} Scale value between 0 and/or equal to 1\n */\nfunction calculateScale( {\n\tframeSize,\n\tcontainerWidth,\n\tmaxContainerWidth,\n\tscaleContainerWidth,\n} ) {\n\treturn (\n\t\t( Math.min( containerWidth, maxContainerWidth ) - frameSize * 2 ) /\n\t\tscaleContainerWidth\n\t);\n}\n\n/**\n * Compute the next scrollHeight based on the transition states.\n *\n * @param {TransitionState} transitionFrom Starting point of the transition\n * @param {TransitionState} transitionTo Ending state of the transition\n * @return {number} Next scrollHeight based on scale and frame value changes.\n */\nfunction computeScrollHeightNext( transitionFrom, transitionTo ) {\n\tconst { scaleValue: prevScale, scrollHeight: prevScrollHeight } =\n\t\ttransitionFrom;\n\tconst { frameSize, scaleValue } = transitionTo;\n\n\treturn prevScrollHeight * ( scaleValue / prevScale ) + frameSize * 2;\n}\n\n/**\n * Compute the next scrollTop position after scaling the iframe content.\n *\n * @param {TransitionState} transitionFrom Starting point of the transition\n * @param {TransitionState} transitionTo Ending state of the transition\n * @return {number} Next scrollTop position after scaling the iframe content.\n */\nfunction computeScrollTopNext( transitionFrom, transitionTo ) {\n\tconst {\n\t\tcontainerHeight: prevContainerHeight,\n\t\tframeSize: prevFrameSize,\n\t\tscaleValue: prevScale,\n\t\tscrollTop: prevScrollTop,\n\t} = transitionFrom;\n\tconst { containerHeight, frameSize, scaleValue, scrollHeight } =\n\t\ttransitionTo;\n\t// Step 0: Start with the current scrollTop.\n\tlet scrollTopNext = prevScrollTop;\n\t// Step 1: Undo the effects of the previous scale and frame around the\n\t// midpoint of the visible area.\n\tscrollTopNext =\n\t\t( scrollTopNext + prevContainerHeight / 2 - prevFrameSize ) /\n\t\t\tprevScale -\n\t\tprevContainerHeight / 2;\n\n\t// Step 2: Apply the new scale and frame around the midpoint of the\n\t// visible area.\n\tscrollTopNext =\n\t\t( scrollTopNext + containerHeight / 2 ) * scaleValue +\n\t\tframeSize -\n\t\tcontainerHeight / 2;\n\n\t// Step 3: Handle an edge case so that you scroll to the top of the\n\t// iframe if the top of the iframe content is visible in the container.\n\t// The same edge case for the bottom is skipped because changing content\n\t// makes calculating it impossible.\n\tscrollTopNext = prevScrollTop <= prevFrameSize ? 0 : scrollTopNext;\n\n\t// This is the scrollTop value if you are scrolled to the bottom of the\n\t// iframe. We can't just let the browser handle it because we need to\n\t// animate the scaling.\n\tconst maxScrollTop = scrollHeight - containerHeight;\n\n\t// Step 4: Clamp the scrollTopNext between the minimum and maximum\n\t// possible scrollTop positions. Round the value to avoid subpixel\n\t// truncation by the browser which sometimes causes a 1px error.\n\treturn Math.round(\n\t\tMath.min( Math.max( 0, scrollTopNext ), Math.max( 0, maxScrollTop ) )\n\t);\n}\n\n/**\n * Generate the keyframes to use for the zoom out animation.\n *\n * @param {TransitionState} transitionFrom Starting transition state.\n * @param {TransitionState} transitionTo Ending transition state.\n * @return {Object[]} An array of keyframes to use for the animation.\n */\nfunction getAnimationKeyframes( transitionFrom, transitionTo ) {\n\tconst {\n\t\tscaleValue: prevScale,\n\t\tframeSize: prevFrameSize,\n\t\tscrollTop,\n\t} = transitionFrom;\n\tconst { scaleValue, frameSize, scrollTop: scrollTopNext } = transitionTo;\n\n\treturn [\n\t\t{\n\t\t\ttranslate: `0 0`,\n\t\t\tscale: prevScale,\n\t\t\tpaddingTop: `${ prevFrameSize / prevScale }px`,\n\t\t\tpaddingBottom: `${ prevFrameSize / prevScale }px`,\n\t\t},\n\t\t{\n\t\t\ttranslate: `0 ${ scrollTop - scrollTopNext }px`,\n\t\t\tscale: scaleValue,\n\t\t\tpaddingTop: `${ frameSize / scaleValue }px`,\n\t\t\tpaddingBottom: `${ frameSize / scaleValue }px`,\n\t\t},\n\t];\n}\n\n/**\n * @typedef {Object} ScaleCanvasResult\n * @property {boolean} isZoomedOut A boolean indicating if the canvas is zoomed out.\n * @property {number} scaleContainerWidth The width of the container used to calculate the scale.\n * @property {Object} contentResizeListener A resize observer for the content.\n * @property {Object} containerResizeListener A resize observer for the container.\n */\n\n/**\n * Handles scaling the canvas for the zoom out mode and animating between\n * the states.\n *\n * @param {Object} options Object of options.\n * @param {number} options.frameSize Size of the frame around the content.\n * @param {Document} options.iframeDocument Document of the iframe.\n * @param {number} options.maxContainerWidth Max width of the canvas to use as the starting scale point. Defaults to 750.\n * @param {number|string} options.scale Scale of the canvas. Can be an decimal between 0 and 1, 1, or 'auto-scaled'.\n * @return {ScaleCanvasResult} Properties of the result.\n */\nexport function useScaleCanvas( {\n\tframeSize,\n\tiframeDocument,\n\tmaxContainerWidth = 750,\n\tscale,\n} ) {\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [\n\t\tcontainerResizeListener,\n\t\t{ width: containerWidth, height: containerHeight },\n\t] = useResizeObserver();\n\n\tconst initialContainerWidthRef = useRef( 0 );\n\tconst isZoomedOut = scale !== 1;\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst isAutoScaled = scale === 'auto-scaled';\n\t// Track if the animation should start when the useEffect runs.\n\tconst startAnimationRef = useRef( false );\n\t// Track the animation so we know if we have an animation running,\n\t// and can cancel it, reverse it, call a finish event, etc.\n\tconst animationRef = useRef( null );\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tinitialContainerWidthRef.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst scaleContainerWidth = Math.max(\n\t\tinitialContainerWidthRef.current,\n\t\tcontainerWidth\n\t);\n\n\tconst scaleValue = isAutoScaled\n\t\t? calculateScale( {\n\t\t\t\tframeSize,\n\t\t\t\tcontainerWidth,\n\t\t\t\tmaxContainerWidth,\n\t\t\t\tscaleContainerWidth,\n\t\t } )\n\t\t: scale;\n\n\t/**\n\t * The starting transition state for the zoom out animation.\n\t * @type {React.RefObject<TransitionState>}\n\t */\n\tconst transitionFromRef = useRef( {\n\t\tscaleValue,\n\t\tframeSize,\n\t\tcontainerHeight: 0,\n\t\tscrollTop: 0,\n\t\tscrollHeight: 0,\n\t} );\n\n\t/**\n\t * The ending transition state for the zoom out animation.\n\t * @type {React.RefObject<TransitionState>}\n\t */\n\tconst transitionToRef = useRef( {\n\t\tscaleValue,\n\t\tframeSize,\n\t\tcontainerHeight: 0,\n\t\tscrollTop: 0,\n\t\tscrollHeight: 0,\n\t} );\n\n\t/**\n\t * Start the zoom out animation. This sets the necessary CSS variables\n\t * for animating the canvas and returns the Animation object.\n\t *\n\t * @return {Animation} The animation object for the zoom out animation.\n\t */\n\tconst startZoomOutAnimation = useCallback( () => {\n\t\tconst { scrollTop } = transitionFromRef.current;\n\t\tconst { scrollTop: scrollTopNext } = transitionToRef.current;\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top',\n\t\t\t`${ scrollTop }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next',\n\t\t\t`${ scrollTopNext }px`\n\t\t);\n\n\t\t// If the container has a scrolllbar, force a scrollbar to prevent the content from shifting while animating.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-overflow-behavior',\n\t\t\ttransitionFromRef.current.scrollHeight ===\n\t\t\t\ttransitionFromRef.current.containerHeight\n\t\t\t\t? 'auto'\n\t\t\t\t: 'scroll'\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.add( 'zoom-out-animation' );\n\n\t\treturn iframeDocument.documentElement.animate(\n\t\t\tgetAnimationKeyframes(\n\t\t\t\ttransitionFromRef.current,\n\t\t\t\ttransitionToRef.current\n\t\t\t),\n\t\t\t{\n\t\t\t\teasing: 'cubic-bezier(0.46, 0.03, 0.52, 0.96)',\n\t\t\t\tduration: 400,\n\t\t\t}\n\t\t);\n\t}, [ iframeDocument ] );\n\n\t/**\n\t * Callback when the zoom out animation is finished.\n\t * - Cleans up animations refs.\n\t * - Adds final CSS vars for scale and frame size to preserve the state.\n\t * - Removes the 'zoom-out-animation' class (which has the fixed positioning).\n\t * - Sets the final scroll position after the canvas is no longer in fixed position.\n\t * - Removes CSS vars related to the animation.\n\t * - Sets the transitionFrom to the transitionTo state to be ready for the next animation.\n\t */\n\tconst finishZoomOutAnimation = useCallback( () => {\n\t\tstartAnimationRef.current = false;\n\t\tanimationRef.current = null;\n\n\t\t// Add our final scale and frame size now that the animation is done.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\ttransitionToRef.current.scaleValue\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\t`${ transitionToRef.current.frameSize }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.remove( 'zoom-out-animation' );\n\n\t\t// Set the final scroll position that was just animated to.\n\t\t// Disable reason: Eslint isn't smart enough to know that this is a\n\t\t// DOM element. https://github.com/facebook/react/issues/31483\n\t\t// eslint-disable-next-line react-compiler/react-compiler\n\t\tiframeDocument.documentElement.scrollTop =\n\t\t\ttransitionToRef.current.scrollTop;\n\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top'\n\t\t);\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next'\n\t\t);\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-overflow-behavior'\n\t\t);\n\n\t\t// Update previous values.\n\t\ttransitionFromRef.current = transitionToRef.current;\n\t}, [ iframeDocument ] );\n\n\tconst previousIsZoomedOut = useRef( false );\n\n\t/**\n\t * Runs when zoom out mode is toggled, and sets the startAnimation flag\n\t * so the animation will start when the next useEffect runs. We _only_\n\t * want to animate when the zoom out mode is toggled, not when the scale\n\t * changes due to the container resizing.\n\t */\n\tuseEffect( () => {\n\t\tconst trigger =\n\t\t\tiframeDocument && previousIsZoomedOut.current !== isZoomedOut;\n\n\t\tpreviousIsZoomedOut.current = isZoomedOut;\n\n\t\tif ( ! trigger ) {\n\t\t\treturn;\n\t\t}\n\n\t\tstartAnimationRef.current = true;\n\n\t\tif ( ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t};\n\t}, [ iframeDocument, isZoomedOut ] );\n\n\t/**\n\t * This handles:\n\t * 1. Setting the correct scale and vars of the canvas when zoomed out\n\t * 2. If zoom out mode has been toggled, runs the animation of zooming in/out\n\t */\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We need to update the appropriate scale to exit from. If sidebars have been opened since setting the\n\t\t// original scale, we will snap to a much smaller scale due to the scale container immediately changing sizes when exiting.\n\t\tif ( isAutoScaled && transitionFromRef.current.scaleValue !== 1 ) {\n\t\t\t// We use containerWidth as the divisor, as scaleContainerWidth will always match the containerWidth when\n\t\t\t// exiting.\n\t\t\ttransitionFromRef.current.scaleValue = calculateScale( {\n\t\t\t\tframeSize: transitionFromRef.current.frameSize,\n\t\t\t\tcontainerWidth,\n\t\t\t\tmaxContainerWidth,\n\t\t\t\tscaleContainerWidth: containerWidth,\n\t\t\t} );\n\t\t}\n\n\t\tif ( scaleValue < 1 ) {\n\t\t\t// If we are not going to animate the transition, set the scale and frame size directly.\n\t\t\t// If we are animating, these values will be set when the animation is finished.\n\t\t\t// Example: Opening sidebars that reduce the scale of the canvas, but we don't want to\n\t\t\t// animate the transition.\n\t\t\tif ( ! startAnimationRef.current ) {\n\t\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\t\t\tscaleValue\n\t\t\t\t);\n\t\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\t\t\t`${ frameSize }px`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t\t`${ contentHeight }px`\n\t\t\t);\n\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t\t`${ containerHeight }px`\n\t\t\t);\n\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t\t`${ containerWidth }px`\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width',\n\t\t\t\t`${ scaleContainerWidth }px`\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Handle the zoom out animation:\n\t\t *\n\t\t * - Get the current scrollTop position.\n\t\t * - Calculate where the same scroll position is after scaling.\n\t\t * - Apply fixed positioning to the canvas with a transform offset\n\t\t * to keep the canvas centered.\n\t\t * - Animate the scale and padding to the new scale and frame size.\n\t\t * - After the animation is complete, remove the fixed positioning\n\t\t * and set the scroll position that keeps everything centered.\n\t\t */\n\t\tif ( startAnimationRef.current ) {\n\t\t\t// Don't allow a new transition to start again unless it was started by the zoom out mode changing.\n\t\t\tstartAnimationRef.current = false;\n\n\t\t\t/**\n\t\t\t * If we already have an animation running, reverse it.\n\t\t\t */\n\t\t\tif ( animationRef.current ) {\n\t\t\t\tanimationRef.current.reverse();\n\t\t\t\t// Swap the transition to/from refs so that we set the correct values when\n\t\t\t\t// finishZoomOutAnimation runs.\n\t\t\t\tconst tempTransitionFrom = transitionFromRef.current;\n\t\t\t\tconst tempTransitionTo = transitionToRef.current;\n\t\t\t\ttransitionFromRef.current = tempTransitionTo;\n\t\t\t\ttransitionToRef.current = tempTransitionFrom;\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * Start a new zoom animation.\n\t\t\t\t */\n\n\t\t\t\t// We can't trust the set value from contentHeight, as it was measured\n\t\t\t\t// before the zoom out mode was changed. After zoom out mode is changed,\n\t\t\t\t// appenders may appear or disappear, so we need to get the height from\n\t\t\t\t// the iframe at this point when we're about to animate the zoom out.\n\t\t\t\t// The iframe scrollTop, scrollHeight, and clientHeight will all be\n\t\t\t\t// the most accurate.\n\t\t\t\ttransitionFromRef.current.scrollTop =\n\t\t\t\t\tiframeDocument.documentElement.scrollTop;\n\t\t\t\ttransitionFromRef.current.scrollHeight =\n\t\t\t\t\tiframeDocument.documentElement.scrollHeight;\n\t\t\t\t// Use containerHeight, as it's the previous container height before the zoom out animation starts.\n\t\t\t\ttransitionFromRef.current.containerHeight = containerHeight;\n\n\t\t\t\ttransitionToRef.current = {\n\t\t\t\t\tscaleValue,\n\t\t\t\t\tframeSize,\n\t\t\t\t\tcontainerHeight:\n\t\t\t\t\t\tiframeDocument.documentElement.clientHeight, // use clientHeight to get the actual height of the new container after zoom state changes have rendered, as it will be the most up-to-date.\n\t\t\t\t};\n\n\t\t\t\ttransitionToRef.current.scrollHeight = computeScrollHeightNext(\n\t\t\t\t\ttransitionFromRef.current,\n\t\t\t\t\ttransitionToRef.current\n\t\t\t\t);\n\t\t\t\ttransitionToRef.current.scrollTop = computeScrollTopNext(\n\t\t\t\t\ttransitionFromRef.current,\n\t\t\t\t\ttransitionToRef.current\n\t\t\t\t);\n\n\t\t\t\tanimationRef.current = startZoomOutAnimation();\n\n\t\t\t\t// If the user prefers reduced motion, finish the animation immediately and set the final state.\n\t\t\t\tif ( prefersReducedMotion ) {\n\t\t\t\t\tfinishZoomOutAnimation();\n\t\t\t\t} else {\n\t\t\t\t\tanimationRef.current.onfinish = finishZoomOutAnimation;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [\n\t\tstartZoomOutAnimation,\n\t\tfinishZoomOutAnimation,\n\t\tprefersReducedMotion,\n\t\tisAutoScaled,\n\t\tscaleValue,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\tcontainerHeight,\n\t\tmaxContainerWidth,\n\t\tscaleContainerWidth,\n\t] );\n\n\treturn {\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t\tcontentResizeListener,\n\t\tcontainerResizeListener,\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW,QAAQ,mBAAmB;AAC/C,SAAS,kBAAkB,yBAAyB;AAqBpD,SAAS,eAAgB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,UACG,KAAK,IAAK,gBAAgB,iBAAkB,IAAI,YAAY,KAC9D;AAEF;AASA,SAAS,wBAAyB,gBAAgB,cAAe;AAChE,QAAM,EAAE,YAAY,WAAW,cAAc,iBAAiB,IAC7D;AACD,QAAM,EAAE,WAAW,WAAW,IAAI;AAElC,SAAO,oBAAqB,aAAa,aAAc,YAAY;AACpE;AASA,SAAS,qBAAsB,gBAAgB,cAAe;AAC7D,QAAM;AAAA,IACL,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACZ,IAAI;AACJ,QAAM,EAAE,iBAAiB,WAAW,YAAY,aAAa,IAC5D;AAED,MAAI,gBAAgB;AAG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gBAAgB,QAAQ;AAAA,IACzB;AACA,mBAAe,gBAAgB,MAAM;AAAA,MACpC;AAAA,MACA,GAAI,gBAAgB,QAAQ,SAAU;AAAA,IACvC;AAEA,mBAAe,gBAAgB,UAAU,OAAQ,oBAAqB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\n\n/**\n * @typedef {Object} TransitionState\n * @property {number} scaleValue Scale of the canvas.\n * @property {number} frameSize Size of the frame/offset around the canvas.\n * @property {number} containerHeight containerHeight of the iframe.\n * @property {number} scrollTop ScrollTop of the iframe.\n * @property {number} scrollHeight ScrollHeight of the iframe.\n */\n\n/**\n * Calculate the scale of the canvas.\n *\n * @param {Object} options Object of options\n * @param {number} options.frameSize Size of the frame/offset around the canvas\n * @param {number} options.containerWidth Actual width of the canvas container\n * @param {number} options.maxContainerWidth Maximum width of the container to use for the scale calculation. This locks the canvas to a maximum width when zooming out.\n * @param {number} options.scaleContainerWidth Width the of the container wrapping the canvas container\n * @return {number} Scale value between 0 and/or equal to 1\n */\nfunction calculateScale( {\n\tframeSize,\n\tcontainerWidth,\n\tmaxContainerWidth,\n\tscaleContainerWidth,\n} ) {\n\treturn (\n\t\t( Math.min( containerWidth, maxContainerWidth ) - frameSize * 2 ) /\n\t\tscaleContainerWidth\n\t);\n}\n\n/**\n * Compute the next scrollHeight based on the transition states.\n *\n * @param {TransitionState} transitionFrom Starting point of the transition\n * @param {TransitionState} transitionTo Ending state of the transition\n * @return {number} Next scrollHeight based on scale and frame value changes.\n */\nfunction computeScrollHeightNext( transitionFrom, transitionTo ) {\n\tconst { scaleValue: prevScale, scrollHeight: prevScrollHeight } =\n\t\ttransitionFrom;\n\tconst { frameSize, scaleValue } = transitionTo;\n\n\treturn prevScrollHeight * ( scaleValue / prevScale ) + frameSize * 2;\n}\n\n/**\n * Compute the next scrollTop position after scaling the iframe content.\n *\n * @param {TransitionState} transitionFrom Starting point of the transition\n * @param {TransitionState} transitionTo Ending state of the transition\n * @return {number} Next scrollTop position after scaling the iframe content.\n */\nfunction computeScrollTopNext( transitionFrom, transitionTo ) {\n\tconst {\n\t\tcontainerHeight: prevContainerHeight,\n\t\tframeSize: prevFrameSize,\n\t\tscaleValue: prevScale,\n\t\tscrollTop: prevScrollTop,\n\t} = transitionFrom;\n\tconst { containerHeight, frameSize, scaleValue, scrollHeight } =\n\t\ttransitionTo;\n\t// Step 0: Start with the current scrollTop.\n\tlet scrollTopNext = prevScrollTop;\n\t// Step 1: Undo the effects of the previous scale and frame around the\n\t// midpoint of the visible area.\n\tscrollTopNext =\n\t\t( scrollTopNext + prevContainerHeight / 2 - prevFrameSize ) /\n\t\t\tprevScale -\n\t\tprevContainerHeight / 2;\n\n\t// Step 2: Apply the new scale and frame around the midpoint of the\n\t// visible area.\n\tscrollTopNext =\n\t\t( scrollTopNext + containerHeight / 2 ) * scaleValue +\n\t\tframeSize -\n\t\tcontainerHeight / 2;\n\n\t// Step 3: Handle an edge case so that you scroll to the top of the\n\t// iframe if the top of the iframe content is visible in the container.\n\t// The same edge case for the bottom is skipped because changing content\n\t// makes calculating it impossible.\n\tscrollTopNext = prevScrollTop <= prevFrameSize ? 0 : scrollTopNext;\n\n\t// This is the scrollTop value if you are scrolled to the bottom of the\n\t// iframe. We can't just let the browser handle it because we need to\n\t// animate the scaling.\n\tconst maxScrollTop = scrollHeight - containerHeight;\n\n\t// Step 4: Clamp the scrollTopNext between the minimum and maximum\n\t// possible scrollTop positions. Round the value to avoid subpixel\n\t// truncation by the browser which sometimes causes a 1px error.\n\treturn Math.round(\n\t\tMath.min( Math.max( 0, scrollTopNext ), Math.max( 0, maxScrollTop ) )\n\t);\n}\n\n/**\n * Generate the keyframes to use for the zoom out animation.\n *\n * @param {TransitionState} transitionFrom Starting transition state.\n * @param {TransitionState} transitionTo Ending transition state.\n * @return {Object[]} An array of keyframes to use for the animation.\n */\nfunction getAnimationKeyframes( transitionFrom, transitionTo ) {\n\tconst {\n\t\tscaleValue: prevScale,\n\t\tframeSize: prevFrameSize,\n\t\tscrollTop,\n\t} = transitionFrom;\n\tconst { scaleValue, frameSize, scrollTop: scrollTopNext } = transitionTo;\n\n\treturn [\n\t\t{\n\t\t\ttranslate: `0 0`,\n\t\t\tscale: prevScale,\n\t\t\tpaddingTop: `${ prevFrameSize / prevScale }px`,\n\t\t\tpaddingBottom: `${ prevFrameSize / prevScale }px`,\n\t\t},\n\t\t{\n\t\t\ttranslate: `0 ${ scrollTop - scrollTopNext }px`,\n\t\t\tscale: scaleValue,\n\t\t\tpaddingTop: `${ frameSize / scaleValue }px`,\n\t\t\tpaddingBottom: `${ frameSize / scaleValue }px`,\n\t\t},\n\t];\n}\n\n/**\n * @typedef {Object} ScaleCanvasResult\n * @property {boolean} isZoomedOut A boolean indicating if the canvas is zoomed out.\n * @property {number} scaleContainerWidth The width of the container used to calculate the scale.\n * @property {Object} contentResizeListener A resize observer for the content.\n * @property {Object} containerResizeListener A resize observer for the container.\n */\n\n/**\n * Handles scaling the canvas for the zoom out mode and animating between\n * the states.\n *\n * @param {Object} options Object of options.\n * @param {number} options.frameSize Size of the frame around the content.\n * @param {Document} options.iframeDocument Document of the iframe.\n * @param {number} options.maxContainerWidth Max width of the canvas to use as the starting scale point. Defaults to 750.\n * @param {number|string} options.scale Scale of the canvas. Can be an decimal between 0 and 1, 1, or 'auto-scaled'.\n * @return {ScaleCanvasResult} Properties of the result.\n */\nexport function useScaleCanvas( {\n\tframeSize,\n\tiframeDocument,\n\tmaxContainerWidth = 750,\n\tscale,\n} ) {\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [\n\t\tcontainerResizeListener,\n\t\t{ width: containerWidth, height: containerHeight },\n\t] = useResizeObserver();\n\n\tconst initialContainerWidthRef = useRef( 0 );\n\tconst isZoomedOut = scale !== 1;\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst isAutoScaled = scale === 'auto-scaled';\n\t// Track if the animation should start when the useEffect runs.\n\tconst startAnimationRef = useRef( false );\n\t// Track the animation so we know if we have an animation running,\n\t// and can cancel it, reverse it, call a finish event, etc.\n\tconst animationRef = useRef( null );\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tinitialContainerWidthRef.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst scaleContainerWidth = Math.max(\n\t\tinitialContainerWidthRef.current,\n\t\tcontainerWidth\n\t);\n\n\tconst scaleValue = isAutoScaled\n\t\t? calculateScale( {\n\t\t\t\tframeSize,\n\t\t\t\tcontainerWidth,\n\t\t\t\tmaxContainerWidth,\n\t\t\t\tscaleContainerWidth,\n\t\t } )\n\t\t: scale;\n\n\t/**\n\t * The starting transition state for the zoom out animation.\n\t * @type {React.RefObject<TransitionState>}\n\t */\n\tconst transitionFromRef = useRef( {\n\t\tscaleValue,\n\t\tframeSize,\n\t\tcontainerHeight: 0,\n\t\tscrollTop: 0,\n\t\tscrollHeight: 0,\n\t} );\n\n\t/**\n\t * The ending transition state for the zoom out animation.\n\t * @type {React.RefObject<TransitionState>}\n\t */\n\tconst transitionToRef = useRef( {\n\t\tscaleValue,\n\t\tframeSize,\n\t\tcontainerHeight: 0,\n\t\tscrollTop: 0,\n\t\tscrollHeight: 0,\n\t} );\n\n\t/**\n\t * Start the zoom out animation. This sets the necessary CSS variables\n\t * for animating the canvas and returns the Animation object.\n\t *\n\t * @return {Animation} The animation object for the zoom out animation.\n\t */\n\tconst startZoomOutAnimation = useCallback( () => {\n\t\tconst { scrollTop } = transitionFromRef.current;\n\t\tconst { scrollTop: scrollTopNext } = transitionToRef.current;\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top',\n\t\t\t`${ scrollTop }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next',\n\t\t\t`${ scrollTopNext }px`\n\t\t);\n\n\t\t// If the container has a scrolllbar, force a scrollbar to prevent the content from shifting while animating.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-overflow-behavior',\n\t\t\ttransitionFromRef.current.scrollHeight ===\n\t\t\t\ttransitionFromRef.current.containerHeight\n\t\t\t\t? 'auto'\n\t\t\t\t: 'scroll'\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.add( 'zoom-out-animation' );\n\n\t\treturn iframeDocument.documentElement.animate(\n\t\t\tgetAnimationKeyframes(\n\t\t\t\ttransitionFromRef.current,\n\t\t\t\ttransitionToRef.current\n\t\t\t),\n\t\t\t{\n\t\t\t\teasing: 'cubic-bezier(0.46, 0.03, 0.52, 0.96)',\n\t\t\t\tduration: 400,\n\t\t\t}\n\t\t);\n\t}, [ iframeDocument ] );\n\n\t/**\n\t * Callback when the zoom out animation is finished.\n\t * - Cleans up animations refs.\n\t * - Adds final CSS vars for scale and frame size to preserve the state.\n\t * - Removes the 'zoom-out-animation' class (which has the fixed positioning).\n\t * - Sets the final scroll position after the canvas is no longer in fixed position.\n\t * - Removes CSS vars related to the animation.\n\t * - Sets the transitionFrom to the transitionTo state to be ready for the next animation.\n\t */\n\tconst finishZoomOutAnimation = useCallback( () => {\n\t\tstartAnimationRef.current = false;\n\t\tanimationRef.current = null;\n\n\t\t// Add our final scale and frame size now that the animation is done.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\ttransitionToRef.current.scaleValue\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\t`${ transitionToRef.current.frameSize }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.remove( 'zoom-out-animation' );\n\n\t\tiframeDocument.documentElement.scrollTop =\n\t\t\ttransitionToRef.current.scrollTop;\n\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top'\n\t\t);\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next'\n\t\t);\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-overflow-behavior'\n\t\t);\n\n\t\t// Update previous values.\n\t\ttransitionFromRef.current = transitionToRef.current;\n\t}, [ iframeDocument ] );\n\n\tconst previousIsZoomedOut = useRef( false );\n\n\t/**\n\t * Runs when zoom out mode is toggled, and sets the startAnimation flag\n\t * so the animation will start when the next useEffect runs. We _only_\n\t * want to animate when the zoom out mode is toggled, not when the scale\n\t * changes due to the container resizing.\n\t */\n\tuseEffect( () => {\n\t\tconst trigger =\n\t\t\tiframeDocument && previousIsZoomedOut.current !== isZoomedOut;\n\n\t\tpreviousIsZoomedOut.current = isZoomedOut;\n\n\t\tif ( ! trigger ) {\n\t\t\treturn;\n\t\t}\n\n\t\tstartAnimationRef.current = true;\n\n\t\tif ( ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t};\n\t}, [ iframeDocument, isZoomedOut ] );\n\n\t/**\n\t * This handles:\n\t * 1. Setting the correct scale and vars of the canvas when zoomed out\n\t * 2. If zoom out mode has been toggled, runs the animation of zooming in/out\n\t */\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We need to update the appropriate scale to exit from. If sidebars have been opened since setting the\n\t\t// original scale, we will snap to a much smaller scale due to the scale container immediately changing sizes when exiting.\n\t\tif ( isAutoScaled && transitionFromRef.current.scaleValue !== 1 ) {\n\t\t\t// We use containerWidth as the divisor, as scaleContainerWidth will always match the containerWidth when\n\t\t\t// exiting.\n\t\t\ttransitionFromRef.current.scaleValue = calculateScale( {\n\t\t\t\tframeSize: transitionFromRef.current.frameSize,\n\t\t\t\tcontainerWidth,\n\t\t\t\tmaxContainerWidth,\n\t\t\t\tscaleContainerWidth: containerWidth,\n\t\t\t} );\n\t\t}\n\n\t\tif ( scaleValue < 1 ) {\n\t\t\t// If we are not going to animate the transition, set the scale and frame size directly.\n\t\t\t// If we are animating, these values will be set when the animation is finished.\n\t\t\t// Example: Opening sidebars that reduce the scale of the canvas, but we don't want to\n\t\t\t// animate the transition.\n\t\t\tif ( ! startAnimationRef.current ) {\n\t\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\t\t\tscaleValue\n\t\t\t\t);\n\t\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\t\t\t`${ frameSize }px`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t\t`${ contentHeight }px`\n\t\t\t);\n\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t\t`${ containerHeight }px`\n\t\t\t);\n\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t\t`${ containerWidth }px`\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width',\n\t\t\t\t`${ scaleContainerWidth }px`\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Handle the zoom out animation:\n\t\t *\n\t\t * - Get the current scrollTop position.\n\t\t * - Calculate where the same scroll position is after scaling.\n\t\t * - Apply fixed positioning to the canvas with a transform offset\n\t\t * to keep the canvas centered.\n\t\t * - Animate the scale and padding to the new scale and frame size.\n\t\t * - After the animation is complete, remove the fixed positioning\n\t\t * and set the scroll position that keeps everything centered.\n\t\t */\n\t\tif ( startAnimationRef.current ) {\n\t\t\t// Don't allow a new transition to start again unless it was started by the zoom out mode changing.\n\t\t\tstartAnimationRef.current = false;\n\n\t\t\t/**\n\t\t\t * If we already have an animation running, reverse it.\n\t\t\t */\n\t\t\tif ( animationRef.current ) {\n\t\t\t\tanimationRef.current.reverse();\n\t\t\t\t// Swap the transition to/from refs so that we set the correct values when\n\t\t\t\t// finishZoomOutAnimation runs.\n\t\t\t\tconst tempTransitionFrom = transitionFromRef.current;\n\t\t\t\tconst tempTransitionTo = transitionToRef.current;\n\t\t\t\ttransitionFromRef.current = tempTransitionTo;\n\t\t\t\ttransitionToRef.current = tempTransitionFrom;\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * Start a new zoom animation.\n\t\t\t\t */\n\n\t\t\t\t// We can't trust the set value from contentHeight, as it was measured\n\t\t\t\t// before the zoom out mode was changed. After zoom out mode is changed,\n\t\t\t\t// appenders may appear or disappear, so we need to get the height from\n\t\t\t\t// the iframe at this point when we're about to animate the zoom out.\n\t\t\t\t// The iframe scrollTop, scrollHeight, and clientHeight will all be\n\t\t\t\t// the most accurate.\n\t\t\t\ttransitionFromRef.current.scrollTop =\n\t\t\t\t\tiframeDocument.documentElement.scrollTop;\n\t\t\t\ttransitionFromRef.current.scrollHeight =\n\t\t\t\t\tiframeDocument.documentElement.scrollHeight;\n\t\t\t\t// Use containerHeight, as it's the previous container height before the zoom out animation starts.\n\t\t\t\ttransitionFromRef.current.containerHeight = containerHeight;\n\n\t\t\t\ttransitionToRef.current = {\n\t\t\t\t\tscaleValue,\n\t\t\t\t\tframeSize,\n\t\t\t\t\tcontainerHeight:\n\t\t\t\t\t\tiframeDocument.documentElement.clientHeight, // use clientHeight to get the actual height of the new container after zoom state changes have rendered, as it will be the most up-to-date.\n\t\t\t\t};\n\n\t\t\t\ttransitionToRef.current.scrollHeight = computeScrollHeightNext(\n\t\t\t\t\ttransitionFromRef.current,\n\t\t\t\t\ttransitionToRef.current\n\t\t\t\t);\n\t\t\t\ttransitionToRef.current.scrollTop = computeScrollTopNext(\n\t\t\t\t\ttransitionFromRef.current,\n\t\t\t\t\ttransitionToRef.current\n\t\t\t\t);\n\n\t\t\t\tanimationRef.current = startZoomOutAnimation();\n\n\t\t\t\t// If the user prefers reduced motion, finish the animation immediately and set the final state.\n\t\t\t\tif ( prefersReducedMotion ) {\n\t\t\t\t\tfinishZoomOutAnimation();\n\t\t\t\t} else {\n\t\t\t\t\tanimationRef.current.onfinish = finishZoomOutAnimation;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [\n\t\tstartZoomOutAnimation,\n\t\tfinishZoomOutAnimation,\n\t\tprefersReducedMotion,\n\t\tisAutoScaled,\n\t\tscaleValue,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\tcontainerHeight,\n\t\tmaxContainerWidth,\n\t\tscaleContainerWidth,\n\t] );\n\n\treturn {\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t\tcontentResizeListener,\n\t\tcontainerResizeListener,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,QAAQ,mBAAmB;AAC/C,SAAS,kBAAkB,yBAAyB;AAqBpD,SAAS,eAAgB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,UACG,KAAK,IAAK,gBAAgB,iBAAkB,IAAI,YAAY,KAC9D;AAEF;AASA,SAAS,wBAAyB,gBAAgB,cAAe;AAChE,QAAM,EAAE,YAAY,WAAW,cAAc,iBAAiB,IAC7D;AACD,QAAM,EAAE,WAAW,WAAW,IAAI;AAElC,SAAO,oBAAqB,aAAa,aAAc,YAAY;AACpE;AASA,SAAS,qBAAsB,gBAAgB,cAAe;AAC7D,QAAM;AAAA,IACL,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,YAAY;AAAA,IAC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AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -164,12 +164,12 @@ var Inserter = class extends Component {
|
|
|
164
164
|
const {
|
|
165
165
|
position,
|
|
166
166
|
hasSingleBlockType,
|
|
167
|
-
|
|
167
|
+
blockToInsert,
|
|
168
168
|
insertOnlyAllowedBlock,
|
|
169
169
|
__experimentalIsQuick: isQuick,
|
|
170
170
|
onSelectOrClose
|
|
171
171
|
} = this.props;
|
|
172
|
-
if (hasSingleBlockType ||
|
|
172
|
+
if (hasSingleBlockType || blockToInsert) {
|
|
173
173
|
return this.renderToggle({ onToggle: insertOnlyAllowedBlock });
|
|
174
174
|
}
|
|
175
175
|
return /* @__PURE__ */ jsx(
|
|
@@ -197,16 +197,19 @@ var inserter_default = compose([
|
|
|
197
197
|
getBlockRootClientId,
|
|
198
198
|
hasInserterItems,
|
|
199
199
|
getAllowedBlocks,
|
|
200
|
-
getDirectInsertBlock
|
|
200
|
+
getDirectInsertBlock,
|
|
201
|
+
getBlockListSettings
|
|
201
202
|
} = select(blockEditorStore);
|
|
202
203
|
const { getBlockVariations, getBlockType } = select(blocksStore);
|
|
203
204
|
rootClientId = rootClientId || getBlockRootClientId(clientId) || void 0;
|
|
204
205
|
const allowedBlocks = getAllowedBlocks(rootClientId);
|
|
205
206
|
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(rootClientId);
|
|
207
|
+
const { defaultBlock } = getBlockListSettings(rootClientId) ?? {};
|
|
206
208
|
const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, "inserter")?.length === 0;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
const allowedBlockType = hasSingleBlockType ? allowedBlocks[0] : null;
|
|
210
|
+
let blockToInsert = directInsertBlock || null;
|
|
211
|
+
if (!blockToInsert && hasSingleBlockType && defaultBlock?.name === allowedBlockType.name) {
|
|
212
|
+
blockToInsert = defaultBlock;
|
|
210
213
|
}
|
|
211
214
|
const defaultBlockType = directInsertBlock ? getBlockType(directInsertBlock.name) : null;
|
|
212
215
|
const appenderLabel = getAppenderLabel(
|
|
@@ -218,7 +221,7 @@ var inserter_default = compose([
|
|
|
218
221
|
hasSingleBlockType,
|
|
219
222
|
blockTitle: allowedBlockType ? allowedBlockType.title : "",
|
|
220
223
|
allowedBlockType,
|
|
221
|
-
|
|
224
|
+
blockToInsert,
|
|
222
225
|
appenderLabel,
|
|
223
226
|
rootClientId
|
|
224
227
|
};
|
|
@@ -233,43 +236,43 @@ var inserter_default = compose([
|
|
|
233
236
|
isAppender,
|
|
234
237
|
hasSingleBlockType,
|
|
235
238
|
allowedBlockType,
|
|
236
|
-
|
|
239
|
+
blockToInsert,
|
|
237
240
|
onSelectOrClose,
|
|
238
241
|
selectBlockOnInsert
|
|
239
242
|
} = ownProps;
|
|
240
|
-
if (!hasSingleBlockType && !
|
|
243
|
+
if (!hasSingleBlockType && !blockToInsert) {
|
|
241
244
|
return;
|
|
242
245
|
}
|
|
246
|
+
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
243
247
|
function getAdjacentBlockAttributes(attributesToCopy) {
|
|
244
|
-
|
|
245
|
-
if (!attributesToCopy || !clientId && !rootClientId) {
|
|
248
|
+
if (!attributesToCopy?.length) {
|
|
246
249
|
return {};
|
|
247
250
|
}
|
|
248
|
-
const
|
|
249
|
-
let adjacentAttributes
|
|
250
|
-
if (
|
|
251
|
-
const parentBlock = getBlock(rootClientId);
|
|
252
|
-
if (parentBlock?.innerBlocks?.length) {
|
|
253
|
-
const lastInnerBlock = parentBlock.innerBlocks[parentBlock.innerBlocks.length - 1];
|
|
254
|
-
if (directInsertBlock && directInsertBlock?.name === lastInnerBlock.name) {
|
|
255
|
-
adjacentAttributes = lastInnerBlock.attributes;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
251
|
+
const { getBlock, getPreviousBlockClientId } = select(blockEditorStore);
|
|
252
|
+
let adjacentAttributes;
|
|
253
|
+
if (clientId) {
|
|
259
254
|
const currentBlock = getBlock(clientId);
|
|
260
255
|
const previousBlock = getBlock(
|
|
261
256
|
getPreviousBlockClientId(clientId)
|
|
262
257
|
);
|
|
263
258
|
if (currentBlock?.name === previousBlock?.name) {
|
|
264
|
-
adjacentAttributes = previousBlock?.attributes
|
|
259
|
+
adjacentAttributes = previousBlock?.attributes;
|
|
265
260
|
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
|
|
261
|
+
} else if (rootClientId) {
|
|
262
|
+
const lastInnerBlock = getBlock(rootClientId)?.innerBlocks?.at(-1);
|
|
263
|
+
if (lastInnerBlock?.name === blockName) {
|
|
264
|
+
adjacentAttributes = lastInnerBlock.attributes;
|
|
270
265
|
}
|
|
271
|
-
}
|
|
272
|
-
|
|
266
|
+
}
|
|
267
|
+
if (!adjacentAttributes) {
|
|
268
|
+
return {};
|
|
269
|
+
}
|
|
270
|
+
return Object.fromEntries(
|
|
271
|
+
attributesToCopy.filter((attr) => attr in adjacentAttributes).map((attr) => [
|
|
272
|
+
attr,
|
|
273
|
+
adjacentAttributes[attr]
|
|
274
|
+
])
|
|
275
|
+
);
|
|
273
276
|
}
|
|
274
277
|
function getInsertionIndex() {
|
|
275
278
|
const {
|
|
@@ -288,26 +291,21 @@ var inserter_default = compose([
|
|
|
288
291
|
return getBlockOrder(rootClientId).length;
|
|
289
292
|
}
|
|
290
293
|
const { insertBlock } = dispatch(blockEditorStore);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
...newAttributes
|
|
299
|
-
});
|
|
300
|
-
} else {
|
|
301
|
-
blockToInsert = createBlock(allowedBlockType.name);
|
|
302
|
-
}
|
|
294
|
+
const newAttributes = getAdjacentBlockAttributes(
|
|
295
|
+
blockToInsert?.attributesToCopy
|
|
296
|
+
);
|
|
297
|
+
const newBlock = createBlock(blockName, {
|
|
298
|
+
...blockToInsert?.attributes || {},
|
|
299
|
+
...newAttributes
|
|
300
|
+
});
|
|
303
301
|
insertBlock(
|
|
304
|
-
|
|
302
|
+
newBlock,
|
|
305
303
|
getInsertionIndex(),
|
|
306
304
|
rootClientId,
|
|
307
305
|
selectBlockOnInsert
|
|
308
306
|
);
|
|
309
307
|
if (onSelectOrClose) {
|
|
310
|
-
onSelectOrClose(
|
|
308
|
+
onSelectOrClose(newBlock);
|
|
311
309
|
}
|
|
312
310
|
const message = sprintf(
|
|
313
311
|
// translators: %s: the name of the block that has been added
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\tappenderLabel,\n\ttoggleProps = {},\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle.toLowerCase()\n\t\t);\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {Element} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {Element} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonClose={ onClose }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t\t'is-quick': isQuick,\n\t\t\t\t} ) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\tconst appenderLabel = getAppenderLabel(\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tdefaultBlockType\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tappenderLabel,\n\t\t\t\trootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( blockToInsert );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AACtB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,UAAU,cAAc;AACjC,SAAS,iBAAiB;AAC1B,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,mBAAmB;AACrC,SAAS,aAAa,SAAS,mBAAmB;AAClD,SAAS,YAAY;AAKrB,OAAO,kBAAkB;AACzB,OAAO,mBAAmB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AA2C/B;AAzCF,IAAM,sBAAsB,CAAE;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAChB,MAAO;AACN,QAAM;AAAA,IACL,IAAI,UAAU;AAAA,IACd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A;AAAA,MACA;AAAA,MACA,eAAe;AAAA,IAChB,IAAI,KAAK;AAET,WAAO,aAAc;AAAA,MACpB;AAAA,MACA;AAAA,MACA,UAAU,YAAY,CAAE;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,cAAe,EAAE,QAAQ,GAAI;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\tappenderLabel,\n\ttoggleProps = {},\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle.toLowerCase()\n\t\t);\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {Element} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {Element} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonClose={ onClose }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tblockToInsert,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || blockToInsert ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t\t'is-quick': isQuick,\n\t\t\t\t} ) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t\tgetBlockListSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\t\t\tconst { defaultBlock } = getBlockListSettings( rootClientId ) ?? {};\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\t\t\tconst allowedBlockType = hasSingleBlockType\n\t\t\t\t? allowedBlocks[ 0 ]\n\t\t\t\t: null;\n\n\t\t\t// Single-block-type parents get adjacent-attribute copying\n\t\t\t// without needing to set `directInsert: true`.\n\t\t\tlet blockToInsert = directInsertBlock || null;\n\t\t\tif (\n\t\t\t\t! blockToInsert &&\n\t\t\t\thasSingleBlockType &&\n\t\t\t\tdefaultBlock?.name === allowedBlockType.name\n\t\t\t) {\n\t\t\t\tblockToInsert = defaultBlock;\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\tconst appenderLabel = getAppenderLabel(\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tdefaultBlockType\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tblockToInsert,\n\t\t\t\tappenderLabel,\n\t\t\t\trootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! blockToInsert ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blockName = blockToInsert?.name ?? allowedBlockType.name;\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tif ( ! attributesToCopy?.length ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\t// Find the adjacent block of the same type whose attributes\n\t\t\t\t\t// should be copied: previous sibling when inserting next to\n\t\t\t\t\t// an existing block, otherwise the last child of the root.\n\t\t\t\t\tlet adjacentAttributes;\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes = previousBlock?.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ( rootClientId ) {\n\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\tgetBlock( rootClientId )?.innerBlocks?.at( -1 );\n\t\t\t\t\t\tif ( lastInnerBlock?.name === blockName ) {\n\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! adjacentAttributes ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tattributesToCopy\n\t\t\t\t\t\t\t.filter( ( attr ) => attr in adjacentAttributes )\n\t\t\t\t\t\t\t.map( ( attr ) => [\n\t\t\t\t\t\t\t\tattr,\n\t\t\t\t\t\t\t\tadjacentAttributes[ attr ],\n\t\t\t\t\t\t\t] )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\t// Attempt to augment the inserted block with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\tblockToInsert?.attributesToCopy\n\t\t\t\t);\n\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\t...( blockToInsert?.attributes || {} ),\n\t\t\t\t\t...newAttributes,\n\t\t\t\t} );\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tnewBlock,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( newBlock );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AACtB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,UAAU,cAAc;AACjC,SAAS,iBAAiB;AAC1B,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,mBAAmB;AACrC,SAAS,aAAa,SAAS,mBAAmB;AAClD,SAAS,YAAY;AAKrB,OAAO,kBAAkB;AACzB,OAAO,mBAAmB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AA2C/B;AAzCF,IAAM,sBAAsB,CAAE;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAChB,MAAO;AACN,QAAM;AAAA,IACL,IAAI,UAAU;AAAA,IACd,OAAO;AAAA,IACP;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AAEJ,MAAI,QAAQ;AACZ,MAAK,CAAE,SAAS,eAAgB;AAE/B,YAAQ;AAAA,EACT,WAAY,CAAE,SAAS,oBAAqB;AAC3C,YAAQ;AAAA;AAAA,MAEP,GAAI,UAAU,qCAAsC;AAAA,MACpD,WAAW,YAAY;AAAA,IACxB;AAAA,EACD,WAAY,CAAE,OAAQ;AACrB,YAAQ,GAAI,aAAa,yCAA0C;AAAA,EACpE;AAGA,WAAS,YAAa,OAAQ;AAC7B,QAAK,UAAW;AACf,eAAU,KAAM;AAAA,IACjB;AACA,QAAK,SAAU;AACd,c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Ef,GAAI,gBAAiB;AAAA,UACrB,iBAAiB;AAAA,QAClB;AACA,cAAO,OAAQ;AAAA,MAChB;AAAA,IACD;AAAA,EACD,CAAE;AAAA;AAAA;AAAA,EAGF;AAAA,IACC,CAAE,EAAE,UAAU,YAAY,cAAc,SAAS,MAChD,YAAc,CAAE,cAAc,CAAE,gBAAgB,CAAE;AAAA,EACpD;AACD,CAAE,EAAG,QAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
forwardRef,
|
|
5
5
|
useState,
|
|
6
6
|
useCallback,
|
|
7
|
+
useEffect,
|
|
7
8
|
useMemo,
|
|
8
9
|
useRef,
|
|
9
10
|
useLayoutEffect
|
|
@@ -128,6 +129,28 @@ function InserterMenu({
|
|
|
128
129
|
);
|
|
129
130
|
const showPatternPanel = selectedTab === "patterns" && !delayedFilterValue && !!selectedPatternCategory;
|
|
130
131
|
const showMediaPanel = selectedTab === "media" && !!selectedMediaCategory;
|
|
132
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
133
|
+
const blocksPanelRef = useRef(null);
|
|
134
|
+
const patternsPanelRef = useRef(null);
|
|
135
|
+
const mediaPanelRef = useRef(null);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
const handleScroll = (event) => {
|
|
138
|
+
setIsScrolled(event.currentTarget.scrollTop > 0);
|
|
139
|
+
};
|
|
140
|
+
const panels = [
|
|
141
|
+
blocksPanelRef.current,
|
|
142
|
+
patternsPanelRef.current,
|
|
143
|
+
mediaPanelRef.current
|
|
144
|
+
].filter(Boolean);
|
|
145
|
+
panels.forEach(
|
|
146
|
+
(panel) => panel.addEventListener("scroll", handleScroll)
|
|
147
|
+
);
|
|
148
|
+
return () => {
|
|
149
|
+
panels.forEach(
|
|
150
|
+
(panel) => panel.removeEventListener("scroll", handleScroll)
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
}, []);
|
|
131
154
|
const inserterSearch = useMemo(() => {
|
|
132
155
|
if (selectedTab === "media") {
|
|
133
156
|
return null;
|
|
@@ -136,7 +159,9 @@ function InserterMenu({
|
|
|
136
159
|
/* @__PURE__ */ jsx(
|
|
137
160
|
SearchControl,
|
|
138
161
|
{
|
|
139
|
-
className: "block-editor-inserter__search",
|
|
162
|
+
className: clsx("block-editor-inserter__search", {
|
|
163
|
+
"is-scrolled": isScrolled
|
|
164
|
+
}),
|
|
140
165
|
onChange: (value) => {
|
|
141
166
|
if (hoveredItem) {
|
|
142
167
|
setHoveredItem(null);
|
|
@@ -177,7 +202,8 @@ function InserterMenu({
|
|
|
177
202
|
clientId,
|
|
178
203
|
rootClientId,
|
|
179
204
|
__experimentalInsertionIndex,
|
|
180
|
-
isAppender
|
|
205
|
+
isAppender,
|
|
206
|
+
isScrolled
|
|
181
207
|
]);
|
|
182
208
|
const blocksTab = useMemo(() => {
|
|
183
209
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -291,6 +317,7 @@ function InserterMenu({
|
|
|
291
317
|
{
|
|
292
318
|
name: "blocks",
|
|
293
319
|
title: __("Blocks"),
|
|
320
|
+
panelRef: blocksPanelRef,
|
|
294
321
|
panel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
295
322
|
inserterSearch,
|
|
296
323
|
selectedTab === "blocks" && !delayedFilterValue && blocksTab
|
|
@@ -299,6 +326,7 @@ function InserterMenu({
|
|
|
299
326
|
{
|
|
300
327
|
name: "patterns",
|
|
301
328
|
title: __("Patterns"),
|
|
329
|
+
panelRef: patternsPanelRef,
|
|
302
330
|
panel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
303
331
|
inserterSearch,
|
|
304
332
|
selectedTab === "patterns" && !delayedFilterValue && patternsTab
|
|
@@ -307,6 +335,7 @@ function InserterMenu({
|
|
|
307
335
|
{
|
|
308
336
|
name: "media",
|
|
309
337
|
title: __("Media"),
|
|
338
|
+
panelRef: mediaPanelRef,
|
|
310
339
|
panel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
311
340
|
inserterSearch,
|
|
312
341
|
mediaTab
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/menu.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { SearchControl, Popover } from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { useDebouncedInput, useViewportMatch } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport Tips from './tips';\nimport InserterPreviewPanel from './preview-panel';\nimport BlockTypesTab from './block-types-tab';\nimport BlockPatternsTab from './block-patterns-tab';\nimport { PatternCategoryPreviews } from './block-patterns-tab/pattern-category-previews';\nimport { MediaTab, MediaCategoryPanel } from './media-tab';\nimport InserterSearchResults from './search-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport { store as blockEditorStore } from '../../store';\nimport TabbedSidebar from '../tabbed-sidebar';\nimport { useZoomOut } from '../../hooks/use-zoom-out';\nimport { unlock } from '../../lock-unlock';\n\nconst NOOP = () => {};\nfunction InserterMenu(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\t__experimentalInsertionIndex,\n\t\tonSelect,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks,\n\t\t__experimentalFilterValue = '',\n\t\tshouldFocusBlock = true,\n\t\tonPatternCategorySelection,\n\t\tonClose,\n\t\t__experimentalInitialTab,\n\t\t__experimentalInitialCategory,\n\t},\n\tref\n) {\n\tconst { isZoomOutMode, hasSectionRootClientId } = useSelect( ( select ) => {\n\t\tconst { isZoomOut, getSectionRootClientId } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\treturn {\n\t\t\tisZoomOutMode: isZoomOut(),\n\t\t\thasSectionRootClientId: !! getSectionRootClientId(),\n\t\t};\n\t}, [] );\n\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( __experimentalFilterValue );\n\tconst [ hoveredItem, setHoveredItem ] = useState( null );\n\tconst [ selectedPatternCategory, setSelectedPatternCategory ] = useState(\n\t\t__experimentalInitialCategory\n\t);\n\tconst [ patternFilter, setPatternFilter ] = useState( 'all' );\n\tconst [ selectedMediaCategory, setSelectedMediaCategory ] =\n\t\tuseState( null );\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst maybeCloseInserter = isMobileViewport ? onClose : NOOP;\n\n\tfunction getInitialTab() {\n\t\tif ( __experimentalInitialTab ) {\n\t\t\treturn __experimentalInitialTab;\n\t\t}\n\n\t\tif ( isZoomOutMode ) {\n\t\t\treturn 'patterns';\n\t\t}\n\n\t\treturn 'blocks';\n\t}\n\tconst [ selectedTab, setSelectedTab ] = useState( getInitialTab() );\n\n\tconst shouldUseZoomOut =\n\t\thasSectionRootClientId &&\n\t\t( selectedTab === 'patterns' || selectedTab === 'media' );\n\n\tuseZoomOut( shouldUseZoomOut && isLargeViewport );\n\n\tconst [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ] =\n\t\tuseInsertionPoint( {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\t\tshouldFocusBlock,\n\t\t} );\n\tconst blockTypesTabRef = useRef();\n\n\tconst onInsert = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock, _rootClientId ) => {\n\t\t\tonInsertBlocks(\n\t\t\t\tblocks,\n\t\t\t\tmeta,\n\t\t\t\tshouldForceFocusBlock,\n\t\t\t\t_rootClientId\n\t\t\t);\n\t\t\tonSelect( blocks );\n\t\t\tmaybeCloseInserter();\n\n\t\t\t// Check for focus loss due to filtering blocks by selected block type\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\tif (\n\t\t\t\t\t! shouldFocusBlock &&\n\t\t\t\t\t! blockTypesTabRef.current?.contains(\n\t\t\t\t\t\tref.current.ownerDocument.activeElement\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\t// There has been a focus loss, so focus the first button in the block types tab\n\t\t\t\t\tblockTypesTabRef.current?.querySelector( 'button' ).focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, ref, shouldFocusBlock ]\n\t);\n\n\tconst onInsertPattern = useCallback(\n\t\t( blocks, patternName, ...args ) => {\n\t\t\tonToggleInsertionPoint( false );\n\t\t\tonInsertBlocks( blocks, { patternName }, ...args );\n\t\t\tonSelect();\n\t\t\tmaybeCloseInserter();\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, onToggleInsertionPoint ]\n\t);\n\n\tconst onHover = useCallback(\n\t\t( item ) => {\n\t\t\tonToggleInsertionPoint( item );\n\t\t\tsetHoveredItem( item );\n\t\t},\n\t\t[ onToggleInsertionPoint, setHoveredItem ]\n\t);\n\n\tconst onClickPatternCategory = useCallback(\n\t\t( patternCategory, filter ) => {\n\t\t\tsetSelectedPatternCategory( patternCategory );\n\t\t\tsetPatternFilter( filter );\n\t\t\tonPatternCategorySelection?.();\n\t\t},\n\t\t[ setSelectedPatternCategory, onPatternCategorySelection ]\n\t);\n\n\tconst showPatternPanel =\n\t\tselectedTab === 'patterns' &&\n\t\t! delayedFilterValue &&\n\t\t!! selectedPatternCategory;\n\n\tconst showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;\n\n\tconst inserterSearch = useMemo( () => {\n\t\tif ( selectedTab === 'media' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SearchControl\n\t\t\t\t\tclassName=\"block-editor-inserter__search\"\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tif ( hoveredItem ) {\n\t\t\t\t\t\t\tsetHoveredItem( null );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetFilterValue( value );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t/>\n\t\t\t\t{ !! delayedFilterValue && (\n\t\t\t\t\t<InserterSearchResults\n\t\t\t\t\t\tfilterValue={ delayedFilterValue }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\t\t__experimentalInsertionIndex\n\t\t\t\t\t\t}\n\t\t\t\t\t\tshowBlockDirectory\n\t\t\t\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\t\t\t\tprioritizePatterns={ selectedTab === 'patterns' }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tselectedTab,\n\t\thoveredItem,\n\t\tsetHoveredItem,\n\t\tsetFilterValue,\n\t\tfilterValue,\n\t\tdelayedFilterValue,\n\t\tonSelect,\n\t\tonHover,\n\t\tshouldFocusBlock,\n\t\tclientId,\n\t\trootClientId,\n\t\t__experimentalInsertionIndex,\n\t\tisAppender,\n\t] );\n\n\tconst blocksTab = useMemo( () => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-inserter__block-list\">\n\t\t\t\t\t<BlockTypesTab\n\t\t\t\t\t\tref={ blockTypesTabRef }\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ showInserterHelpPanel && (\n\t\t\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t\t\t\t{ __( 'A tip for using the block editor' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t<Tips />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tonHover,\n\t\tshowMostUsedBlocks,\n\t\tshowInserterHelpPanel,\n\t] );\n\n\tconst patternsTab = useMemo( () => {\n\t\treturn (\n\t\t\t<BlockPatternsTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\tonSelectCategory={ onClickPatternCategory }\n\t\t\t\tselectedCategory={ selectedPatternCategory }\n\t\t\t>\n\t\t\t\t{ showPatternPanel && (\n\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\t\t\tcategory={ selectedPatternCategory }\n\t\t\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPatternsTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsertPattern,\n\t\tonClickPatternCategory,\n\t\tpatternFilter,\n\t\tselectedPatternCategory,\n\t\tshowPatternPanel,\n\t] );\n\n\tconst mediaTab = useMemo( () => {\n\t\treturn (\n\t\t\t<MediaTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tselectedCategory={ selectedMediaCategory }\n\t\t\t\tonSelectCategory={ setSelectedMediaCategory }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t>\n\t\t\t\t{ showMediaPanel && (\n\t\t\t\t\t<MediaCategoryPanel\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tcategory={ selectedMediaCategory }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</MediaTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tselectedMediaCategory,\n\t\tsetSelectedMediaCategory,\n\t\tshowMediaPanel,\n\t] );\n\n\tconst handleSetSelectedTab = ( value ) => {\n\t\t// If no longer on patterns tab remove the category setting.\n\t\tif ( value !== 'patterns' ) {\n\t\t\tsetSelectedPatternCategory( null );\n\t\t}\n\t\tsetSelectedTab( value );\n\t};\n\n\t// Focus first active tab, if any\n\tconst tabsRef = useRef();\n\tuseLayoutEffect( () => {\n\t\tif ( tabsRef.current ) {\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\ttabsRef.current\n\t\t\t\t\t.querySelector( '[role=\"tab\"][aria-selected=\"true\"]' )\n\t\t\t\t\t?.focus();\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'block-editor-inserter__menu', {\n\t\t\t\t'show-panel': showPatternPanel || showMediaPanel,\n\t\t\t\t'is-zoom-out': isZoomOutMode,\n\t\t\t} ) }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__main-area\">\n\t\t\t\t<TabbedSidebar\n\t\t\t\t\tref={ tabsRef }\n\t\t\t\t\tonSelect={ handleSetSelectedTab }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tselectedTab={ selectedTab }\n\t\t\t\t\tcloseButtonLabel={ __( 'Close Block Inserter' ) }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'blocks',\n\t\t\t\t\t\t\ttitle: __( 'Blocks' ),\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'blocks' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tblocksTab }\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\t{\n\t\t\t\t\t\t\tname: 'patterns',\n\t\t\t\t\t\t\ttitle: __( 'Patterns' ),\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'patterns' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tpatternsTab }\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\t{\n\t\t\t\t\t\t\tname: 'media',\n\t\t\t\t\t\t\ttitle: __( 'Media' ),\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ mediaTab }\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] }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{ showInserterHelpPanel && hoveredItem && (\n\t\t\t\t<Popover\n\t\t\t\t\tclassName=\"block-editor-inserter__preview-container__popover\"\n\t\t\t\t\tplacement=\"right-start\"\n\t\t\t\t\toffset={ 16 }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tanimate={ false }\n\t\t\t\t>\n\t\t\t\t\t<InserterPreviewPanel item={ hoveredItem } />\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport const PrivateInserterMenu = forwardRef( InserterMenu );\n\nfunction PublicInserterMenu( props, ref ) {\n\treturn (\n\t\t<PrivateInserterMenu\n\t\t\t{ ...props }\n\t\t\tonPatternCategorySelection={ NOOP }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( PublicInserterMenu );\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,eAAe;AACvC,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB,wBAAwB;AACpD,SAAS,iBAAiB;AAK1B,OAAO,UAAU;AACjB,OAAO,0BAA0B;AACjC,OAAO,mBAAmB;AAC1B,OAAO,sBAAsB;AAC7B,SAAS,+BAA+B;AACxC,SAAS,UAAU,0BAA0B;AAC7C,OAAO,2BAA2B;AAClC,OAAO,uBAAuB;AAC9B,SAAS,SAAS,wBAAwB;AAC1C,OAAO,mBAAmB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { SearchControl, Popover } from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { useDebouncedInput, useViewportMatch } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport Tips from './tips';\nimport InserterPreviewPanel from './preview-panel';\nimport BlockTypesTab from './block-types-tab';\nimport BlockPatternsTab from './block-patterns-tab';\nimport { PatternCategoryPreviews } from './block-patterns-tab/pattern-category-previews';\nimport { MediaTab, MediaCategoryPanel } from './media-tab';\nimport InserterSearchResults from './search-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport { store as blockEditorStore } from '../../store';\nimport TabbedSidebar from '../tabbed-sidebar';\nimport { useZoomOut } from '../../hooks/use-zoom-out';\nimport { unlock } from '../../lock-unlock';\n\nconst NOOP = () => {};\nfunction InserterMenu(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\t__experimentalInsertionIndex,\n\t\tonSelect,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks,\n\t\t__experimentalFilterValue = '',\n\t\tshouldFocusBlock = true,\n\t\tonPatternCategorySelection,\n\t\tonClose,\n\t\t__experimentalInitialTab,\n\t\t__experimentalInitialCategory,\n\t},\n\tref\n) {\n\tconst { isZoomOutMode, hasSectionRootClientId } = useSelect( ( select ) => {\n\t\tconst { isZoomOut, getSectionRootClientId } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\treturn {\n\t\t\tisZoomOutMode: isZoomOut(),\n\t\t\thasSectionRootClientId: !! getSectionRootClientId(),\n\t\t};\n\t}, [] );\n\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( __experimentalFilterValue );\n\tconst [ hoveredItem, setHoveredItem ] = useState( null );\n\tconst [ selectedPatternCategory, setSelectedPatternCategory ] = useState(\n\t\t__experimentalInitialCategory\n\t);\n\tconst [ patternFilter, setPatternFilter ] = useState( 'all' );\n\tconst [ selectedMediaCategory, setSelectedMediaCategory ] =\n\t\tuseState( null );\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst maybeCloseInserter = isMobileViewport ? onClose : NOOP;\n\n\tfunction getInitialTab() {\n\t\tif ( __experimentalInitialTab ) {\n\t\t\treturn __experimentalInitialTab;\n\t\t}\n\n\t\tif ( isZoomOutMode ) {\n\t\t\treturn 'patterns';\n\t\t}\n\n\t\treturn 'blocks';\n\t}\n\tconst [ selectedTab, setSelectedTab ] = useState( getInitialTab() );\n\n\tconst shouldUseZoomOut =\n\t\thasSectionRootClientId &&\n\t\t( selectedTab === 'patterns' || selectedTab === 'media' );\n\n\tuseZoomOut( shouldUseZoomOut && isLargeViewport );\n\n\tconst [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ] =\n\t\tuseInsertionPoint( {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\t\tshouldFocusBlock,\n\t\t} );\n\tconst blockTypesTabRef = useRef();\n\n\tconst onInsert = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock, _rootClientId ) => {\n\t\t\tonInsertBlocks(\n\t\t\t\tblocks,\n\t\t\t\tmeta,\n\t\t\t\tshouldForceFocusBlock,\n\t\t\t\t_rootClientId\n\t\t\t);\n\t\t\tonSelect( blocks );\n\t\t\tmaybeCloseInserter();\n\n\t\t\t// Check for focus loss due to filtering blocks by selected block type\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\tif (\n\t\t\t\t\t! shouldFocusBlock &&\n\t\t\t\t\t! blockTypesTabRef.current?.contains(\n\t\t\t\t\t\tref.current.ownerDocument.activeElement\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\t// There has been a focus loss, so focus the first button in the block types tab\n\t\t\t\t\tblockTypesTabRef.current?.querySelector( 'button' ).focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, ref, shouldFocusBlock ]\n\t);\n\n\tconst onInsertPattern = useCallback(\n\t\t( blocks, patternName, ...args ) => {\n\t\t\tonToggleInsertionPoint( false );\n\t\t\tonInsertBlocks( blocks, { patternName }, ...args );\n\t\t\tonSelect();\n\t\t\tmaybeCloseInserter();\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, onToggleInsertionPoint ]\n\t);\n\n\tconst onHover = useCallback(\n\t\t( item ) => {\n\t\t\tonToggleInsertionPoint( item );\n\t\t\tsetHoveredItem( item );\n\t\t},\n\t\t[ onToggleInsertionPoint, setHoveredItem ]\n\t);\n\n\tconst onClickPatternCategory = useCallback(\n\t\t( patternCategory, filter ) => {\n\t\t\tsetSelectedPatternCategory( patternCategory );\n\t\t\tsetPatternFilter( filter );\n\t\t\tonPatternCategorySelection?.();\n\t\t},\n\t\t[ setSelectedPatternCategory, onPatternCategorySelection ]\n\t);\n\n\tconst showPatternPanel =\n\t\tselectedTab === 'patterns' &&\n\t\t! delayedFilterValue &&\n\t\t!! selectedPatternCategory;\n\n\tconst showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;\n\n\tconst [ isScrolled, setIsScrolled ] = useState( false );\n\tconst blocksPanelRef = useRef( null );\n\tconst patternsPanelRef = useRef( null );\n\tconst mediaPanelRef = useRef( null );\n\tuseEffect( () => {\n\t\tconst handleScroll = ( event ) => {\n\t\t\tsetIsScrolled( event.currentTarget.scrollTop > 0 );\n\t\t};\n\t\tconst panels = [\n\t\t\tblocksPanelRef.current,\n\t\t\tpatternsPanelRef.current,\n\t\t\tmediaPanelRef.current,\n\t\t].filter( Boolean );\n\t\tpanels.forEach( ( panel ) =>\n\t\t\tpanel.addEventListener( 'scroll', handleScroll )\n\t\t);\n\n\t\treturn () => {\n\t\t\tpanels.forEach( ( panel ) =>\n\t\t\t\tpanel.removeEventListener( 'scroll', handleScroll )\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst inserterSearch = useMemo( () => {\n\t\tif ( selectedTab === 'media' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SearchControl\n\t\t\t\t\tclassName={ clsx( 'block-editor-inserter__search', {\n\t\t\t\t\t\t'is-scrolled': isScrolled,\n\t\t\t\t\t} ) }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tif ( hoveredItem ) {\n\t\t\t\t\t\t\tsetHoveredItem( null );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetFilterValue( value );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t/>\n\t\t\t\t{ !! delayedFilterValue && (\n\t\t\t\t\t<InserterSearchResults\n\t\t\t\t\t\tfilterValue={ delayedFilterValue }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\t\t__experimentalInsertionIndex\n\t\t\t\t\t\t}\n\t\t\t\t\t\tshowBlockDirectory\n\t\t\t\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\t\t\t\tprioritizePatterns={ selectedTab === 'patterns' }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tselectedTab,\n\t\thoveredItem,\n\t\tsetHoveredItem,\n\t\tsetFilterValue,\n\t\tfilterValue,\n\t\tdelayedFilterValue,\n\t\tonSelect,\n\t\tonHover,\n\t\tshouldFocusBlock,\n\t\tclientId,\n\t\trootClientId,\n\t\t__experimentalInsertionIndex,\n\t\tisAppender,\n\t\tisScrolled,\n\t] );\n\n\tconst blocksTab = useMemo( () => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-inserter__block-list\">\n\t\t\t\t\t<BlockTypesTab\n\t\t\t\t\t\tref={ blockTypesTabRef }\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ showInserterHelpPanel && (\n\t\t\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t\t\t\t{ __( 'A tip for using the block editor' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t<Tips />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tonHover,\n\t\tshowMostUsedBlocks,\n\t\tshowInserterHelpPanel,\n\t] );\n\n\tconst patternsTab = useMemo( () => {\n\t\treturn (\n\t\t\t<BlockPatternsTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\tonSelectCategory={ onClickPatternCategory }\n\t\t\t\tselectedCategory={ selectedPatternCategory }\n\t\t\t>\n\t\t\t\t{ showPatternPanel && (\n\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\t\t\tcategory={ selectedPatternCategory }\n\t\t\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPatternsTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsertPattern,\n\t\tonClickPatternCategory,\n\t\tpatternFilter,\n\t\tselectedPatternCategory,\n\t\tshowPatternPanel,\n\t] );\n\n\tconst mediaTab = useMemo( () => {\n\t\treturn (\n\t\t\t<MediaTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tselectedCategory={ selectedMediaCategory }\n\t\t\t\tonSelectCategory={ setSelectedMediaCategory }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t>\n\t\t\t\t{ showMediaPanel && (\n\t\t\t\t\t<MediaCategoryPanel\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tcategory={ selectedMediaCategory }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</MediaTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tselectedMediaCategory,\n\t\tsetSelectedMediaCategory,\n\t\tshowMediaPanel,\n\t] );\n\n\tconst handleSetSelectedTab = ( value ) => {\n\t\t// If no longer on patterns tab remove the category setting.\n\t\tif ( value !== 'patterns' ) {\n\t\t\tsetSelectedPatternCategory( null );\n\t\t}\n\t\tsetSelectedTab( value );\n\t};\n\n\t// Focus first active tab, if any\n\tconst tabsRef = useRef();\n\tuseLayoutEffect( () => {\n\t\tif ( tabsRef.current ) {\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\ttabsRef.current\n\t\t\t\t\t.querySelector( '[role=\"tab\"][aria-selected=\"true\"]' )\n\t\t\t\t\t?.focus();\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'block-editor-inserter__menu', {\n\t\t\t\t'show-panel': showPatternPanel || showMediaPanel,\n\t\t\t\t'is-zoom-out': isZoomOutMode,\n\t\t\t} ) }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__main-area\">\n\t\t\t\t<TabbedSidebar\n\t\t\t\t\tref={ tabsRef }\n\t\t\t\t\tonSelect={ handleSetSelectedTab }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tselectedTab={ selectedTab }\n\t\t\t\t\tcloseButtonLabel={ __( 'Close Block Inserter' ) }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'blocks',\n\t\t\t\t\t\t\ttitle: __( 'Blocks' ),\n\t\t\t\t\t\t\tpanelRef: blocksPanelRef,\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'blocks' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tblocksTab }\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\t{\n\t\t\t\t\t\t\tname: 'patterns',\n\t\t\t\t\t\t\ttitle: __( 'Patterns' ),\n\t\t\t\t\t\t\tpanelRef: patternsPanelRef,\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'patterns' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tpatternsTab }\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\t{\n\t\t\t\t\t\t\tname: 'media',\n\t\t\t\t\t\t\ttitle: __( 'Media' ),\n\t\t\t\t\t\t\tpanelRef: mediaPanelRef,\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ mediaTab }\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] }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{ showInserterHelpPanel && hoveredItem && (\n\t\t\t\t<Popover\n\t\t\t\t\tclassName=\"block-editor-inserter__preview-container__popover\"\n\t\t\t\t\tplacement=\"right-start\"\n\t\t\t\t\toffset={ 16 }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tanimate={ false }\n\t\t\t\t>\n\t\t\t\t\t<InserterPreviewPanel item={ hoveredItem } />\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport const PrivateInserterMenu = forwardRef( InserterMenu );\n\nfunction PublicInserterMenu( props, ref ) {\n\treturn (\n\t\t<PrivateInserterMenu\n\t\t\t{ ...props }\n\t\t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AAAA,gBACN,OAAO,GAAI,QAAS;AAAA,gBACpB,UAAU;AAAA,gBACV,OACC,iCACG;AAAA;AAAA,kBACA,gBAAgB,YACjB,CAAE,sBACF;AAAA,mBACF;AAAA,cAEF;AAAA,cACA;AAAA,gBACC,MAAM;AAAA,gBACN,OAAO,GAAI,UAAW;AAAA,gBACtB,UAAU;AAAA,gBACV,OACC,iCACG;AAAA;AAAA,kBACA,gBAAgB,cACjB,CAAE,sBACF;AAAA,mBACF;AAAA,cAEF;AAAA,cACA;AAAA,gBACC,MAAM;AAAA,gBACN,OAAO,GAAI,OAAQ;AAAA,gBACnB,UAAU;AAAA,gBACV,OACC,iCACG;AAAA;AAAA,kBACA;AAAA,mBACH;AAAA,cAEF;AAAA,YACD;AAAA;AAAA,QACD,GACD;AAAA,QACE,yBAAyB,eAC1B;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,WAAU;AAAA,YACV,QAAS;AAAA,YACT,cAAe;AAAA,YACf,SAAU;AAAA,YAEV,8BAAC,wBAAqB,MAAO,aAAc;AAAA;AAAA,QAC5C;AAAA;AAAA;AAAA,EAEF;AAEF;AAEO,IAAM,sBAAsB,WAAY,YAAa;AAE5D,SAAS,mBAAoB,OAAO,KAAM;AACzC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,4BAA6B;AAAA,MAC7B;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,eAAQ,WAAY,kBAAmB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var globalTips = [
|
|
|
27
27
|
];
|
|
28
28
|
function Tips() {
|
|
29
29
|
const [randomIndex] = useState(
|
|
30
|
-
Math.floor(Math.random() * globalTips.length)
|
|
30
|
+
() => Math.floor(Math.random() * globalTips.length)
|
|
31
31
|
);
|
|
32
32
|
return /* @__PURE__ */ jsx(Tip, { children: globalTips[randomIndex] });
|
|
33
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/tips.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement, useState } from '@wordpress/element';\nimport { Tip } from '@wordpress/components';\n\nconst globalTips = [\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\t__( 'Drag files into the editor to automatically insert media blocks.' ),\n\t__( \"Change a block's type by pressing the block icon on the toolbar.\" ),\n];\n\nfunction Tips() {\n\tconst [ randomIndex ] = useState(
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,0BAA0B,gBAAgB;AACnD,SAAS,WAAW;AAOX;AALT,IAAM,aAAa;AAAA,EAClB;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA,GAAI,kEAAmE;AAAA,EACvE,GAAI,kEAAmE;AACxE;AAEA,SAAS,OAAO;AACf,QAAM,CAAE,WAAY,IAAI;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement, useState } from '@wordpress/element';\nimport { Tip } from '@wordpress/components';\n\nconst globalTips = [\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\t__( 'Drag files into the editor to automatically insert media blocks.' ),\n\t__( \"Change a block's type by pressing the block icon on the toolbar.\" ),\n];\n\nfunction Tips() {\n\tconst [ randomIndex ] = useState( () =>\n\t\tMath.floor( Math.random() * globalTips.length )\n\t);\n\n\treturn <Tip>{ globalTips[ randomIndex ] }</Tip>;\n}\n\nexport default Tips;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,0BAA0B,gBAAgB;AACnD,SAAS,WAAW;AAOX;AALT,IAAM,aAAa;AAAA,EAClB;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA,GAAI,kEAAmE;AAAA,EACvE,GAAI,kEAAmE;AACxE;AAEA,SAAS,OAAO;AACf,QAAM,CAAE,WAAY,IAAI;AAAA,IAAU,MACjC,KAAK,MAAO,KAAK,OAAO,IAAI,WAAW,MAAO;AAAA,EAC/C;AAEA,SAAO,oBAAC,OAAM,qBAAY,WAAY,GAAG;AAC1C;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|