@wordpress/block-editor 12.19.1 → 12.19.3
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/build/components/block-tools/insertion-point.js +4 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +5 -10
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +4 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +61 -24
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +3 -3
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +8 -6
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/iframe/index.js +4 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/rich-text/index.js +7 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +1 -0
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-enter.js +1 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +25 -26
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/hooks/background.js +4 -2
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +0 -17
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +8 -4
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/get-block-settings.js +17 -4
- package/build/store/get-block-settings.js.map +1 -1
- package/build/store/index.js +0 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +5 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +8 -0
- package/build/store/private-keys.js.map +1 -0
- package/build/store/private-selectors.js +6 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +7 -12
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -2
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +6 -11
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -4
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +61 -25
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +3 -3
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +9 -7
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +1 -0
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +1 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +25 -26
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/hooks/background.js +4 -2
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +0 -17
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +8 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/get-block-settings.js +16 -4
- package/build-module/store/get-block-settings.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +5 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +1 -0
- package/build-module/store/private-selectors.js +5 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -9
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -2
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +0 -10
- package/build-style/style.css +0 -10
- package/package.json +31 -31
- package/src/components/block-tools/insertion-point.js +6 -1
- package/src/components/global-styles/advanced-panel.js +6 -12
- package/src/components/global-styles/border-panel.js +4 -6
- package/src/components/global-styles/get-global-styles-changes.js +68 -28
- package/src/components/global-styles/shadow-panel-components.js +3 -3
- package/src/components/global-styles/style.scss +0 -10
- package/src/components/global-styles/test/get-global-styles-changes.js +114 -75
- package/src/components/global-styles/typography-panel.js +11 -7
- package/src/components/iframe/index.js +4 -1
- package/src/components/inserter/media-tab/media-preview.js +6 -1
- package/src/components/rich-text/index.js +12 -5
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/use-enter.js +1 -0
- package/src/components/rich-text/use-paste-handler.js +26 -25
- package/src/hooks/background.js +5 -2
- package/src/hooks/use-bindings-attributes.js +0 -21
- package/src/hooks/utils.js +24 -8
- package/src/private-apis.js +2 -0
- package/src/store/get-block-settings.js +15 -4
- package/src/store/index.js +0 -2
- package/src/store/private-actions.js +9 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +4 -7
- package/src/store/reducer.js +0 -10
- package/src/store/selectors.js +7 -15
- package/src/store/utils.js +7 -2
- package/build/store/resolvers.js +0 -27
- package/build/store/resolvers.js.map +0 -1
- package/build-module/store/resolvers.js +0 -20
- package/build-module/store/resolvers.js.map +0 -1
- package/src/store/resolvers.js +0 -17
|
@@ -84,9 +84,12 @@ function InbetweenInsertionPointPopover({
|
|
|
84
84
|
isInserterShown: insertionPoint?.__unstableWithInserter
|
|
85
85
|
};
|
|
86
86
|
}, []);
|
|
87
|
+
const {
|
|
88
|
+
getBlockEditingMode
|
|
89
|
+
} = (0, _data.useSelect)(_store.store);
|
|
87
90
|
const disableMotion = (0, _compose.useReducedMotion)();
|
|
88
91
|
function onClick(event) {
|
|
89
|
-
if (event.target === ref.current && nextClientId) {
|
|
92
|
+
if (event.target === ref.current && nextClientId && getBlockEditingMode(nextClientId) !== 'disabled') {
|
|
90
93
|
selectBlock(nextClientId, -1);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_data","_element","_components","_compose","_inserter","_store","_inbetween","_dropZone","InsertionPointOpenRef","exports","createContext","InbetweenInsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","operation","nearestSide","selectBlock","hideInsertionPoint","useDispatch","blockEditorStore","openRef","useContext","ref","useRef","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","isDistractionFree","isNavigationMode","useSelect","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","getSettings","_isNavigationMode","insertionPoint","order","length","_previousClientId","index","_nextClientId","settings","__unstableWithInserter","disableMotion","useReducedMotion","onClick","event","target","current","maybeHideInserterPoint","onFocus","lineVariants","start","opacity","scale","rest","transition","delay","type","hover","inserterVariants","orientationClassname","className","classnames","_react","createElement","default","__unstableMotion","div","layout","initial","animate","whileHover","whileTap","exit","tabIndex","onHoverEnd","variants","position","clientId","__experimentalIsQuick","onToggle","isOpen","onSelectOrClose","InsertionPoint","props","isVisible","isBlockListEmpty","isBlockInsertionPointVisible","getBlockCount","blockInsertionPoint","key"],"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, createContext, useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverInbetween from '../block-popover/inbetween';\nimport BlockDropZonePopover from '../block-popover/drop-zone';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InbetweenInsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\toperation = 'insert',\n\tnearestSide = 'right',\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t\tisDistractionFree,\n\t\tisNavigationMode,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t\tgetSettings,\n\t\t\tisNavigationMode: _isNavigationMode,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisNavigationMode: _isNavigationMode(),\n\t\t\tisDistractionFree: settings.isDistractionFree,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\n\tconst disableMotion = useReducedMotion();\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\topacity: 0,\n\t\t\tscale: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\topacity: 1,\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: isInserterShown ? 0.5 : 0, type: 'tween' },\n\t\t},\n\t\thover: {\n\t\t\topacity: 1,\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.5, type: 'tween' },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.4, type: 'tween' },\n\t\t},\n\t};\n\n\tif ( isDistractionFree && ! isNavigationMode ) {\n\t\treturn null;\n\t}\n\n\tconst orientationClassname =\n\t\torientation === 'horizontal' || operation === 'group'\n\t\t\t? 'is-horizontal'\n\t\t\t: 'is-vertical';\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\torientationClassname\n\t);\n\n\treturn (\n\t\t<BlockPopoverInbetween\n\t\t\tpreviousClientId={ previousClientId }\n\t\t\tnextClientId={ nextClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\toperation={ operation }\n\t\t\tnearestSide={ nearestSide }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': isInserterShown,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t\tdata-testid=\"block-list-insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ isInserterShown && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</BlockPopoverInbetween>\n\t);\n}\n\nexport default function InsertionPoint( props ) {\n\tconst { insertionPoint, isVisible, isBlockListEmpty } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockCount,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockInsertionPoint = getBlockInsertionPoint();\n\t\t\treturn {\n\t\t\t\tinsertionPoint: blockInsertionPoint,\n\t\t\t\tisVisible: isBlockInsertionPointVisible(),\n\t\t\t\tisBlockListEmpty:\n\t\t\t\t\tgetBlockCount( blockInsertionPoint?.rootClientId ) === 0,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t! isVisible ||\n\t\t// Don't render the insertion point if the block list is empty.\n\t\t// The insertion point will be represented by the appender instead.\n\t\tisBlockListEmpty\n\t) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Render a popover that overlays the block when the desired operation is to replace it.\n\t * Otherwise, render a popover in between blocks for the indication of inserting between them.\n\t */\n\treturn insertionPoint.operation === 'replace' ? (\n\t\t<BlockDropZonePopover\n\t\t\t// Force remount to trigger the animation.\n\t\t\tkey={ `${ insertionPoint.rootClientId }-${ insertionPoint.index }` }\n\t\t\t{ ...props }\n\t\t/>\n\t) : (\n\t\t<InbetweenInsertionPointPopover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ireDefault","require","_data","_element","_components","_compose","_inserter","_store","_inbetween","_dropZone","InsertionPointOpenRef","exports","createContext","InbetweenInsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","operation","nearestSide","selectBlock","hideInsertionPoint","useDispatch","blockEditorStore","openRef","useContext","ref","useRef","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","isDistractionFree","isNavigationMode","useSelect","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","getSettings","_isNavigationMode","insertionPoint","order","length","_previousClientId","index","_nextClientId","settings","__unstableWithInserter","getBlockEditingMode","disableMotion","useReducedMotion","onClick","event","target","current","maybeHideInserterPoint","onFocus","lineVariants","start","opacity","scale","rest","transition","delay","type","hover","inserterVariants","orientationClassname","className","classnames","_react","createElement","default","__unstableMotion","div","layout","initial","animate","whileHover","whileTap","exit","tabIndex","onHoverEnd","variants","position","clientId","__experimentalIsQuick","onToggle","isOpen","onSelectOrClose","InsertionPoint","props","isVisible","isBlockListEmpty","isBlockInsertionPointVisible","getBlockCount","blockInsertionPoint","key"],"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, createContext, useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverInbetween from '../block-popover/inbetween';\nimport BlockDropZonePopover from '../block-popover/drop-zone';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InbetweenInsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\toperation = 'insert',\n\tnearestSide = 'right',\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t\tisDistractionFree,\n\t\tisNavigationMode,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t\tgetSettings,\n\t\t\tisNavigationMode: _isNavigationMode,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisNavigationMode: _isNavigationMode(),\n\t\t\tisDistractionFree: settings.isDistractionFree,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst { getBlockEditingMode } = useSelect( blockEditorStore );\n\n\tconst disableMotion = useReducedMotion();\n\n\tfunction onClick( event ) {\n\t\tif (\n\t\t\tevent.target === ref.current &&\n\t\t\tnextClientId &&\n\t\t\tgetBlockEditingMode( nextClientId ) !== 'disabled'\n\t\t) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\topacity: 0,\n\t\t\tscale: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\topacity: 1,\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: isInserterShown ? 0.5 : 0, type: 'tween' },\n\t\t},\n\t\thover: {\n\t\t\topacity: 1,\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.5, type: 'tween' },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.4, type: 'tween' },\n\t\t},\n\t};\n\n\tif ( isDistractionFree && ! isNavigationMode ) {\n\t\treturn null;\n\t}\n\n\tconst orientationClassname =\n\t\torientation === 'horizontal' || operation === 'group'\n\t\t\t? 'is-horizontal'\n\t\t\t: 'is-vertical';\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\torientationClassname\n\t);\n\n\treturn (\n\t\t<BlockPopoverInbetween\n\t\t\tpreviousClientId={ previousClientId }\n\t\t\tnextClientId={ nextClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\toperation={ operation }\n\t\t\tnearestSide={ nearestSide }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': isInserterShown,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t\tdata-testid=\"block-list-insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ isInserterShown && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</BlockPopoverInbetween>\n\t);\n}\n\nexport default function InsertionPoint( props ) {\n\tconst { insertionPoint, isVisible, isBlockListEmpty } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockCount,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockInsertionPoint = getBlockInsertionPoint();\n\t\t\treturn {\n\t\t\t\tinsertionPoint: blockInsertionPoint,\n\t\t\t\tisVisible: isBlockInsertionPointVisible(),\n\t\t\t\tisBlockListEmpty:\n\t\t\t\t\tgetBlockCount( blockInsertionPoint?.rootClientId ) === 0,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t! isVisible ||\n\t\t// Don't render the insertion point if the block list is empty.\n\t\t// The insertion point will be represented by the appender instead.\n\t\tisBlockListEmpty\n\t) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Render a popover that overlays the block when the desired operation is to replace it.\n\t * Otherwise, render a popover in between blocks for the indication of inserting between them.\n\t */\n\treturn insertionPoint.operation === 'replace' ? (\n\t\t<BlockDropZonePopover\n\t\t\t// Force remount to trigger the animation.\n\t\t\tkey={ `${ insertionPoint.rootClientId }-${ insertionPoint.index }` }\n\t\t\t{ ...props }\n\t\t/>\n\t) : (\n\t\t<InbetweenInsertionPointPopover\n\t\t\toperation={ insertionPoint.operation }\n\t\t\tnearestSide={ insertionPoint.nearestSide }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,SAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAA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AAS;IAAEC;EAAiB,CAAC,GAAG,IAAA/D,eAAS,EAC9DC,MAAM,IAAM;IACb,MAAM;MACLG,sBAAsB;MACtB4D,4BAA4B;MAC5BC;IACD,CAAC,GAAGhE,MAAM,CAAEb,YAAiB,CAAC;IAC9B,MAAM8E,mBAAmB,GAAG9D,sBAAsB,CAAC,CAAC;IACpD,OAAO;MACNM,cAAc,EAAEwD,mBAAmB;MACnCJ,SAAS,EAAEE,4BAA4B,CAAC,CAAC;MACzCD,gBAAgB,EACfE,aAAa,CAAEC,mBAAmB,EAAEtE,YAAa,CAAC,KAAK;IACzD,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,IACC,CAAEkE,SAAS;EACX;EACA;EACAC,gBAAgB,EACf;IACD,OAAO,IAAI;EACZ;;EAEA;AACD;AACA;AACA;EACC,OAAOrD,cAAc,CAAC3B,SAAS,KAAK,SAAS,GAC5C,IAAAyD,MAAA,CAAAC,aAAA,EAACjE,SAAA,CAAAkE;EACA;EAAA;IACAyB,GAAG,EAAI,GAAGzD,cAAc,CAACd,YAAc,IAAIc,cAAc,CAACI,KAAO,EAAG;IAAA,GAC/D+C;EAAK,CACV,CAAC,GAEF,IAAArB,MAAA,CAAAC,aAAA,EAAC7D,8BAA8B;IAC9BG,SAAS,EAAG2B,cAAc,CAAC3B,SAAW;IACtCC,WAAW,EAAG0B,cAAc,CAAC1B,WAAa;IAAA,GACrC6E;EAAK,CACV,CACD;AACF"}
|
|
@@ -9,7 +9,6 @@ var _react = require("react");
|
|
|
9
9
|
var _components = require("@wordpress/components");
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
var _i18n = require("@wordpress/i18n");
|
|
12
|
-
var _icons = require("@wordpress/icons");
|
|
13
12
|
var _transformStyles = _interopRequireDefault(require("../../utils/transform-styles"));
|
|
14
13
|
/**
|
|
15
14
|
* WordPress dependencies
|
|
@@ -53,7 +52,10 @@ function AdvancedPanel({
|
|
|
53
52
|
}
|
|
54
53
|
return (0, _react.createElement)(_components.__experimentalVStack, {
|
|
55
54
|
spacing: 3
|
|
56
|
-
}, (0, _react.createElement)(_components.
|
|
55
|
+
}, cssError && (0, _react.createElement)(_components.Notice, {
|
|
56
|
+
status: "error",
|
|
57
|
+
onRemove: () => setCSSError(null)
|
|
58
|
+
}, cssError), (0, _react.createElement)(_components.TextareaControl, {
|
|
57
59
|
label: (0, _i18n.__)('Additional CSS'),
|
|
58
60
|
__nextHasNoMarginBottom: true,
|
|
59
61
|
value: customCSS,
|
|
@@ -61,13 +63,6 @@ function AdvancedPanel({
|
|
|
61
63
|
onBlur: handleOnBlur,
|
|
62
64
|
className: "block-editor-global-styles-advanced-panel__custom-css-input",
|
|
63
65
|
spellCheck: false
|
|
64
|
-
})
|
|
65
|
-
text: cssError
|
|
66
|
-
}, (0, _react.createElement)("div", {
|
|
67
|
-
className: "block-editor-global-styles-advanced-panel__custom-css-validation-wrapper"
|
|
68
|
-
}, (0, _react.createElement)(_icons.Icon, {
|
|
69
|
-
icon: _icons.info,
|
|
70
|
-
className: "block-editor-global-styles-advanced-panel__custom-css-validation-icon"
|
|
71
|
-
}))));
|
|
66
|
+
}));
|
|
72
67
|
}
|
|
73
68
|
//# sourceMappingURL=advanced-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","_transformStyles","_interopRequireDefault","AdvancedPanel","value","onChange","inheritedValue","cssError","setCSSError","useState","customCSS","css","handleOnChange","newValue","transformed","transformStyles","handleOnBlur","event","target","__","_react","createElement","__experimentalVStack","spacing","Notice","status","onRemove","TextareaControl","label","__nextHasNoMarginBottom","onBlur","className","spellCheck"],"sources":["@wordpress/block-editor/src/components/global-styles/advanced-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tTextareaControl,\n\tNotice,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { default as transformStyles } from '../../utils/transform-styles';\n\nexport default function AdvancedPanel( {\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n} ) {\n\t// Custom CSS\n\tconst [ cssError, setCSSError ] = useState( null );\n\tconst customCSS = inheritedValue?.css;\n\tfunction handleOnChange( newValue ) {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\tcss: newValue,\n\t\t} );\n\t\tif ( cssError ) {\n\t\t\tconst [ transformed ] = transformStyles(\n\t\t\t\t[ { css: newValue } ],\n\t\t\t\t'.editor-styles-wrapper'\n\t\t\t);\n\t\t\tif ( transformed ) {\n\t\t\t\tsetCSSError( null );\n\t\t\t}\n\t\t}\n\t}\n\tfunction handleOnBlur( event ) {\n\t\tif ( ! event?.target?.value ) {\n\t\t\tsetCSSError( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ transformed ] = transformStyles(\n\t\t\t[ { css: event.target.value } ],\n\t\t\t'.editor-styles-wrapper'\n\t\t);\n\n\t\tsetCSSError(\n\t\t\ttransformed === null\n\t\t\t\t? __( 'There is an error with your CSS structure.' )\n\t\t\t\t: null\n\t\t);\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t{ cssError && (\n\t\t\t\t<Notice status=\"error\" onRemove={ () => setCSSError( null ) }>\n\t\t\t\t\t{ cssError }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ __( 'Additional CSS' ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ customCSS }\n\t\t\t\tonChange={ ( newValue ) => handleOnChange( newValue ) }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tclassName=\"block-editor-global-styles-advanced-panel__custom-css-input\"\n\t\t\t\tspellCheck={ false }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC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2B,MAAM;IAACC,MAAM,EAAC,OAAO;IAACC,QAAQ,EAAGA,CAAA,KAAMlB,WAAW,CAAE,IAAK;EAAG,GAC1DD,QACK,CACR,EACD,IAAAa,MAAA,CAAAC,aAAA,EAACxB,WAAA,CAAA8B,eAAe;IACfC,KAAK,EAAG,IAAAT,QAAE,EAAE,gBAAiB,CAAG;IAChCU,uBAAuB;IACvBzB,KAAK,EAAGM,SAAW;IACnBL,QAAQ,EAAKQ,QAAQ,IAAMD,cAAc,CAAEC,QAAS,CAAG;IACvDiB,MAAM,EAAGd,YAAc;IACvBe,SAAS,EAAC,6DAA6D;IACvEC,UAAU,EAAG;EAAO,CACpB,CACM,CAAC;AAEX"}
|
|
@@ -79,6 +79,7 @@ function BorderPanel({
|
|
|
79
79
|
name,
|
|
80
80
|
defaultControls = DEFAULT_CONTROLS
|
|
81
81
|
}) {
|
|
82
|
+
var _settings$shadow$pres, _overrideOrigins;
|
|
82
83
|
const colors = (0, _hooks.useColorsPerOrigin)(settings);
|
|
83
84
|
const decodeValue = (0, _element.useCallback)(rawValue => (0, _utils.getValueFromVariable)({
|
|
84
85
|
settings
|
|
@@ -136,10 +137,10 @@ function BorderPanel({
|
|
|
136
137
|
|
|
137
138
|
// Shadow
|
|
138
139
|
const shadow = decodeValue(inheritedValue?.shadow);
|
|
139
|
-
const shadowPresets = settings?.shadow?.presets;
|
|
140
|
-
const
|
|
140
|
+
const shadowPresets = (_settings$shadow$pres = settings?.shadow?.presets) !== null && _settings$shadow$pres !== void 0 ? _settings$shadow$pres : {};
|
|
141
|
+
const overriddenShadowPresets = (_overrideOrigins = (0, _getBlockSettings.overrideOrigins)(shadowPresets)) !== null && _overrideOrigins !== void 0 ? _overrideOrigins : [];
|
|
141
142
|
const setShadow = newValue => {
|
|
142
|
-
const slug =
|
|
143
|
+
const slug = overriddenShadowPresets?.find(({
|
|
143
144
|
shadow: shadowName
|
|
144
145
|
}) => shadowName === newValue)?.slug;
|
|
145
146
|
onChange((0, _object.setImmutably)(value, ['shadow'], slug ? `var:preset|shadow|${slug}` : newValue || undefined));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","_borderRadiusControl","_interopRequireDefault","_hooks","_utils","_getBlockSettings","_object","_border","_shadowPanelComponents","useHasShadowControl","settings","shadow","useHasBorderPanel","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","border","color","radius","style","width","BorderToolsPanel","resetAllFilter","onChange","value","panelId","children","label","resetAll","updatedValue","_react","createElement","__experimentalToolsPanel","dropdownMenuProps","TOOLSPANEL_DROPDOWNMENU_PROPS","DEFAULT_CONTROLS","BorderPanel","as","Wrapper","inheritedValue","name","defaultControls","colors","useColorsPerOrigin","decodeValue","useCallback","rawValue","getValueFromVariable","encodeColorValue","colorValue","allColors","flatMap","originColors","colorObject","find","slug","useMemo","hasSplitBorders","borderValue","forEach","side","undefined","setBorder","newBorder","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","newBorderRadius","hasBorderRadius","borderValues","Object","entries","hasShadowControl","shadowPresets","presets","mergedShadowPresets","mergeOrigins","setShadow","newValue","shadowName","setImmutably","hasShadow","resetShadow","resetBorder","onBorderChange","updatedBorder","previousValue","showBorderByDefault","getBorderPanelLabel","blockName","hasBorderControl","__experimentalToolsPanelItem","hasValue","isDefinedBorder","__","onDeselect","isShownByDefault","__experimentalBorderBoxControl","enableAlpha","enableStyle","popoverOffset","popoverPlacement","__experimentalIsRenderedInSidebar","size","hideLabelFromVision","default","values","BaseControl","VisualLabel","__experimentalItemGroup","isBordered","isSeparated","ShadowPopover","onShadowChange"],"sources":["@wordpress/block-editor/src/components/global-styles/border-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalItemGroup as ItemGroup,\n\tBaseControl,\n} from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../border-radius-control';\nimport { useColorsPerOrigin } from './hooks';\nimport { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';\nimport { mergeOrigins } from '../../store/get-block-settings';\nimport { setImmutably } from '../../utils/object';\nimport { getBorderPanelLabel } from '../../hooks/border';\nimport { ShadowPopover } from './shadow-panel-components';\n\nfunction useHasShadowControl( settings ) {\n\treturn !! settings?.shadow;\n}\n\nexport function useHasBorderPanel( settings ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( settings ),\n\t\tuseHasBorderRadiusControl( settings ),\n\t\tuseHasBorderStyleControl( settings ),\n\t\tuseHasBorderWidthControl( settings ),\n\t\tuseHasShadowControl( settings ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( settings ) {\n\treturn settings?.border?.color;\n}\n\nfunction useHasBorderRadiusControl( settings ) {\n\treturn settings?.border?.radius;\n}\n\nfunction useHasBorderStyleControl( settings ) {\n\treturn settings?.border?.style;\n}\n\nfunction useHasBorderWidthControl( settings ) {\n\treturn settings?.border?.width;\n}\n\nfunction BorderToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n\tlabel,\n} ) {\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ label }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tradius: true,\n\tcolor: true,\n\twidth: true,\n\tshadow: false,\n};\n\nexport default function BorderPanel( {\n\tas: Wrapper = BorderToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tname,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst colors = useColorsPerOrigin( settings );\n\tconst decodeValue = useCallback(\n\t\t( rawValue ) => getValueFromVariable( { settings }, '', rawValue ),\n\t\t[ settings ]\n\t);\n\tconst encodeColorValue = ( colorValue ) => {\n\t\tconst allColors = colors.flatMap(\n\t\t\t( { colors: originColors } ) => originColors\n\t\t);\n\t\tconst colorObject = allColors.find(\n\t\t\t( { color } ) => color === colorValue\n\t\t);\n\t\treturn colorObject\n\t\t\t? 'var:preset|color|' + colorObject.slug\n\t\t\t: colorValue;\n\t};\n\tconst border = useMemo( () => {\n\t\tif ( hasSplitBorders( inheritedValue?.border ) ) {\n\t\t\tconst borderValue = { ...inheritedValue?.border };\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tborderValue[ side ] = {\n\t\t\t\t\t...borderValue[ side ],\n\t\t\t\t\tcolor: decodeValue( borderValue[ side ]?.color ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn borderValue;\n\t\t}\n\t\treturn {\n\t\t\t...inheritedValue?.border,\n\t\t\tcolor: inheritedValue?.border?.color\n\t\t\t\t? decodeValue( inheritedValue?.border?.color )\n\t\t\t\t: undefined,\n\t\t};\n\t}, [ inheritedValue?.border, decodeValue ] );\n\tconst setBorder = ( newBorder ) =>\n\t\tonChange( { ...value, border: newBorder } );\n\tconst showBorderColor = useHasBorderColorControl( settings );\n\tconst showBorderStyle = useHasBorderStyleControl( settings );\n\tconst showBorderWidth = useHasBorderWidthControl( settings );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( settings );\n\tconst borderRadiusValues = decodeValue( border?.radius );\n\tconst setBorderRadius = ( newBorderRadius ) =>\n\t\tsetBorder( { ...border, radius: newBorderRadius } );\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = value?.border?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\tconst hasShadowControl = useHasShadowControl( settings );\n\n\t// Shadow\n\tconst shadow = decodeValue( inheritedValue?.shadow );\n\tconst shadowPresets = settings?.shadow?.presets;\n\tconst mergedShadowPresets = shadowPresets\n\t\t? mergeOrigins( shadowPresets )\n\t\t: [];\n\tconst setShadow = ( newValue ) => {\n\t\tconst slug = mergedShadowPresets?.find(\n\t\t\t( { shadow: shadowName } ) => shadowName === newValue\n\t\t)?.slug;\n\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'shadow' ],\n\t\t\t\tslug ? `var:preset|shadow|${ slug }` : newValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasShadow = () => !! value?.shadow;\n\tconst resetShadow = () => setShadow( undefined );\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: value?.border?.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Ensure we have a visible border style when a border width or\n\t\t// color is being selected.\n\t\tconst updatedBorder = { ...newBorder };\n\n\t\tif ( hasSplitBorders( updatedBorder ) ) {\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tif ( updatedBorder[ side ] ) {\n\t\t\t\t\tupdatedBorder[ side ] = {\n\t\t\t\t\t\t...updatedBorder[ side ],\n\t\t\t\t\t\tcolor: encodeColorValue( updatedBorder[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( updatedBorder ) {\n\t\t\tupdatedBorder.color = encodeColorValue( updatedBorder.color );\n\t\t}\n\n\t\t// As radius is maintained separately to color, style, and width\n\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t// global styles are saved.\n\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tborder: undefined,\n\t\t\tshadow: undefined,\n\t\t};\n\t}, [] );\n\n\tconst showBorderByDefault =\n\t\tdefaultControls?.color || defaultControls?.width;\n\n\tconst label = getBorderPanelLabel( {\n\t\tblockName: name,\n\t\thasShadowControl,\n\t\thasBorderControl:\n\t\t\tshowBorderColor ||\n\t\t\tshowBorderStyle ||\n\t\t\tshowBorderWidth ||\n\t\t\tshowBorderRadius,\n\t} );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( value?.border ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\thideLabelFromVision={ ! hasShadowControl }\n\t\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ defaultControls.radius }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetBorderRadius( newValue || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasShadowControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Shadow' ) }\n\t\t\t\t\thasValue={ hasShadow }\n\t\t\t\t\tonDeselect={ resetShadow }\n\t\t\t\t\tisShownByDefault={ defaultControls.shadow }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Shadow' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t\t<ShadowPopover\n\t\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\t\tonShadowChange={ setShadow }\n\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ItemGroup>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,oBAAA,GAAAC,sBAA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CAAAC,aAAA,EAAClC,oBAAA,CAAA+G,OAAmB;IACnBC,MAAM,EAAGzC,kBAAoB;IAC7B7C,QAAQ,EAAK0D,QAAQ,IAAM;MAC1BZ,eAAe,CAAEY,QAAQ,IAAIpB,SAAU,CAAC;IACzC;EAAG,CACH,CACc,CAChB,EACCc,gBAAgB,IACjB,IAAA7C,MAAA,CAAAC,aAAA,EAACtC,WAAA,CAAAqG,4BAAc;IACdnE,KAAK,EAAG,IAAAsE,QAAE,EAAE,QAAS,CAAG;IACxBF,QAAQ,EAAGX,SAAW;IACtBc,UAAU,EAAGb,WAAa;IAC1Bc,gBAAgB,EAAG1D,eAAe,CAAClC,MAAQ;IAC3CkB,OAAO,EAAGA;EAAS,GAEnB,IAAAK,MAAA,CAAAC,aAAA,EAACtC,WAAA,CAAAqH,WAAW,CAACC,WAAW;IAAC1E,EAAE,EAAC;EAAQ,GACjC,IAAA4D,QAAE,EAAE,QAAS,CACS,CAAC,EAC1B,IAAAnE,MAAA,CAAAC,aAAA,EAACtC,WAAA,CAAAuH,uBAAS;IAACC,UAAU;IAACC,WAAW;EAAA,GAChC,IAAApF,MAAA,CAAAC,aAAA,EAAC3B,sBAAA,CAAA+G,aAAa;IACb5G,MAAM,EAAGA,MAAQ;IACjB6G,cAAc,EAAGpC,SAAW;IAC5B1E,QAAQ,EAAGA;EAAU,CACrB,CACS,CACI,CAET,CAAC;AAEZ"}
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","_borderRadiusControl","_interopRequireDefault","_hooks","_utils","_getBlockSettings","_object","_border","_shadowPanelComponents","useHasShadowControl","settings","shadow","useHasBorderPanel","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","border","color","radius","style","width","BorderToolsPanel","resetAllFilter","onChange","value","panelId","children","label","resetAll","updatedValue","_react","createElement","__experimentalToolsPanel","dropdownMenuProps","TOOLSPANEL_DROPDOWNMENU_PROPS","DEFAULT_CONTROLS","BorderPanel","as","Wrapper","inheritedValue","name","defaultControls","_settings$shadow$pres","_overrideOrigins","colors","useColorsPerOrigin","decodeValue","useCallback","rawValue","getValueFromVariable","encodeColorValue","colorValue","allColors","flatMap","originColors","colorObject","find","slug","useMemo","hasSplitBorders","borderValue","forEach","side","undefined","setBorder","newBorder","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","newBorderRadius","hasBorderRadius","borderValues","Object","entries","hasShadowControl","shadowPresets","presets","overriddenShadowPresets","overrideOrigins","setShadow","newValue","shadowName","setImmutably","hasShadow","resetShadow","resetBorder","onBorderChange","updatedBorder","previousValue","showBorderByDefault","getBorderPanelLabel","blockName","hasBorderControl","__experimentalToolsPanelItem","hasValue","isDefinedBorder","__","onDeselect","isShownByDefault","__experimentalBorderBoxControl","enableAlpha","enableStyle","popoverOffset","popoverPlacement","__experimentalIsRenderedInSidebar","size","hideLabelFromVision","default","values","BaseControl","VisualLabel","__experimentalItemGroup","isBordered","isSeparated","ShadowPopover","onShadowChange"],"sources":["@wordpress/block-editor/src/components/global-styles/border-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalItemGroup as ItemGroup,\n\tBaseControl,\n} from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../border-radius-control';\nimport { useColorsPerOrigin } from './hooks';\nimport { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';\nimport { overrideOrigins } from '../../store/get-block-settings';\nimport { setImmutably } from '../../utils/object';\nimport { getBorderPanelLabel } from '../../hooks/border';\nimport { ShadowPopover } from './shadow-panel-components';\n\nfunction useHasShadowControl( settings ) {\n\treturn !! settings?.shadow;\n}\n\nexport function useHasBorderPanel( settings ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( settings ),\n\t\tuseHasBorderRadiusControl( settings ),\n\t\tuseHasBorderStyleControl( settings ),\n\t\tuseHasBorderWidthControl( settings ),\n\t\tuseHasShadowControl( settings ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( settings ) {\n\treturn settings?.border?.color;\n}\n\nfunction useHasBorderRadiusControl( settings ) {\n\treturn settings?.border?.radius;\n}\n\nfunction useHasBorderStyleControl( settings ) {\n\treturn settings?.border?.style;\n}\n\nfunction useHasBorderWidthControl( settings ) {\n\treturn settings?.border?.width;\n}\n\nfunction BorderToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n\tlabel,\n} ) {\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ label }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tradius: true,\n\tcolor: true,\n\twidth: true,\n\tshadow: false,\n};\n\nexport default function BorderPanel( {\n\tas: Wrapper = BorderToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tname,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst colors = useColorsPerOrigin( settings );\n\tconst decodeValue = useCallback(\n\t\t( rawValue ) => getValueFromVariable( { settings }, '', rawValue ),\n\t\t[ settings ]\n\t);\n\tconst encodeColorValue = ( colorValue ) => {\n\t\tconst allColors = colors.flatMap(\n\t\t\t( { colors: originColors } ) => originColors\n\t\t);\n\t\tconst colorObject = allColors.find(\n\t\t\t( { color } ) => color === colorValue\n\t\t);\n\t\treturn colorObject\n\t\t\t? 'var:preset|color|' + colorObject.slug\n\t\t\t: colorValue;\n\t};\n\tconst border = useMemo( () => {\n\t\tif ( hasSplitBorders( inheritedValue?.border ) ) {\n\t\t\tconst borderValue = { ...inheritedValue?.border };\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tborderValue[ side ] = {\n\t\t\t\t\t...borderValue[ side ],\n\t\t\t\t\tcolor: decodeValue( borderValue[ side ]?.color ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn borderValue;\n\t\t}\n\t\treturn {\n\t\t\t...inheritedValue?.border,\n\t\t\tcolor: inheritedValue?.border?.color\n\t\t\t\t? decodeValue( inheritedValue?.border?.color )\n\t\t\t\t: undefined,\n\t\t};\n\t}, [ inheritedValue?.border, decodeValue ] );\n\tconst setBorder = ( newBorder ) =>\n\t\tonChange( { ...value, border: newBorder } );\n\tconst showBorderColor = useHasBorderColorControl( settings );\n\tconst showBorderStyle = useHasBorderStyleControl( settings );\n\tconst showBorderWidth = useHasBorderWidthControl( settings );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( settings );\n\tconst borderRadiusValues = decodeValue( border?.radius );\n\tconst setBorderRadius = ( newBorderRadius ) =>\n\t\tsetBorder( { ...border, radius: newBorderRadius } );\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = value?.border?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\tconst hasShadowControl = useHasShadowControl( settings );\n\n\t// Shadow\n\tconst shadow = decodeValue( inheritedValue?.shadow );\n\tconst shadowPresets = settings?.shadow?.presets ?? {};\n\tconst overriddenShadowPresets = overrideOrigins( shadowPresets ) ?? [];\n\tconst setShadow = ( newValue ) => {\n\t\tconst slug = overriddenShadowPresets?.find(\n\t\t\t( { shadow: shadowName } ) => shadowName === newValue\n\t\t)?.slug;\n\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'shadow' ],\n\t\t\t\tslug ? `var:preset|shadow|${ slug }` : newValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasShadow = () => !! value?.shadow;\n\tconst resetShadow = () => setShadow( undefined );\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: value?.border?.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Ensure we have a visible border style when a border width or\n\t\t// color is being selected.\n\t\tconst updatedBorder = { ...newBorder };\n\n\t\tif ( hasSplitBorders( updatedBorder ) ) {\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tif ( updatedBorder[ side ] ) {\n\t\t\t\t\tupdatedBorder[ side ] = {\n\t\t\t\t\t\t...updatedBorder[ side ],\n\t\t\t\t\t\tcolor: encodeColorValue( updatedBorder[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( updatedBorder ) {\n\t\t\tupdatedBorder.color = encodeColorValue( updatedBorder.color );\n\t\t}\n\n\t\t// As radius is maintained separately to color, style, and width\n\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t// global styles are saved.\n\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tborder: undefined,\n\t\t\tshadow: undefined,\n\t\t};\n\t}, [] );\n\n\tconst showBorderByDefault =\n\t\tdefaultControls?.color || defaultControls?.width;\n\n\tconst label = getBorderPanelLabel( {\n\t\tblockName: name,\n\t\thasShadowControl,\n\t\thasBorderControl:\n\t\t\tshowBorderColor ||\n\t\t\tshowBorderStyle ||\n\t\t\tshowBorderWidth ||\n\t\t\tshowBorderRadius,\n\t} );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( value?.border ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\thideLabelFromVision={ ! hasShadowControl }\n\t\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ defaultControls.radius }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetBorderRadius( newValue || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasShadowControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Shadow' ) }\n\t\t\t\t\thasValue={ hasShadow }\n\t\t\t\t\tonDeselect={ resetShadow }\n\t\t\t\t\tisShownByDefault={ defaultControls.shadow }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Shadow' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t\t<ShadowPopover\n\t\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\t\tonShadowChange={ setShadow }\n\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ItemGroup>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,oBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,sBAAA,GAAAV,OAAA;AAxBA;AACA;AACA;;AAaA;AACA;AACA;;AASA,SAASW,mBAAmBA,CAAEC,QAAQ,EAAG;EACxC,OAAO,CAAC,CAAEA,QAAQ,EAAEC,MAAM;AAC3B;AAEO,SAASC,iBAAiBA,CAAEF,QAAQ,EAAG;EAC7C,MAAMG,QAAQ,GAAG,CAChBC,wBAA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AG,IAAAwE,QAAE,EAAE,QAAS,CAAG;IACxBF,QAAQ,EAAGX,SAAW;IACtBc,UAAU,EAAGb,WAAa;IAC1Bc,gBAAgB,EAAG5D,eAAe,CAAClC,MAAQ;IAC3CkB,OAAO,EAAGA;EAAS,GAEnB,IAAAK,MAAA,CAAAC,aAAA,EAACtC,WAAA,CAAAuH,WAAW,CAACC,WAAW;IAAC5E,EAAE,EAAC;EAAQ,GACjC,IAAA8D,QAAE,EAAE,QAAS,CACS,CAAC,EAC1B,IAAArE,MAAA,CAAAC,aAAA,EAACtC,WAAA,CAAAyH,uBAAS;IAACC,UAAU;IAACC,WAAW;EAAA,GAChC,IAAAtF,MAAA,CAAAC,aAAA,EAAC3B,sBAAA,CAAAiH,aAAa;IACb9G,MAAM,EAAGA,MAAQ;IACjB+G,cAAc,EAAGpC,SAAW;IAC5B5E,QAAQ,EAAGA;EAAU,CACrB,CACS,CACI,CAET,CAAC;AAEZ"}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = getGlobalStylesChanges;
|
|
8
|
+
exports.getGlobalStylesChangelist = getGlobalStylesChangelist;
|
|
8
9
|
var _memize = _interopRequireDefault(require("memize"));
|
|
9
10
|
var _i18n = require("@wordpress/i18n");
|
|
10
11
|
var _blocks = require("@wordpress/blocks");
|
|
@@ -29,8 +30,8 @@ const translationMap = {
|
|
|
29
30
|
h4: (0, _i18n.__)('H4'),
|
|
30
31
|
h5: (0, _i18n.__)('H5'),
|
|
31
32
|
h6: (0, _i18n.__)('H6'),
|
|
32
|
-
'settings.color': (0, _i18n.__)('Color
|
|
33
|
-
'settings.typography': (0, _i18n.__)('Typography
|
|
33
|
+
'settings.color': (0, _i18n.__)('Color'),
|
|
34
|
+
'settings.typography': (0, _i18n.__)('Typography'),
|
|
34
35
|
'styles.color': (0, _i18n.__)('Colors'),
|
|
35
36
|
'styles.spacing': (0, _i18n.__)('Spacing'),
|
|
36
37
|
'styles.typography': (0, _i18n.__)('Typography')
|
|
@@ -59,10 +60,7 @@ function getTranslation(key) {
|
|
|
59
60
|
return blockName || keyArray[1];
|
|
60
61
|
}
|
|
61
62
|
if (keyArray?.[0] === 'elements') {
|
|
62
|
-
|
|
63
|
-
return (0, _i18n.sprintf)(
|
|
64
|
-
// translators: %s: element name, e.g., heading button, link, caption.
|
|
65
|
-
(0, _i18n.__)('%s element'), elementName);
|
|
63
|
+
return translationMap[keyArray[1]] || keyArray[1];
|
|
66
64
|
}
|
|
67
65
|
return undefined;
|
|
68
66
|
}
|
|
@@ -105,7 +103,7 @@ function deepCompare(changedObject, originalObject, parentPath = '') {
|
|
|
105
103
|
*
|
|
106
104
|
* @param {Object} next The changed object to compare.
|
|
107
105
|
* @param {Object} previous The original object to compare against.
|
|
108
|
-
* @return {
|
|
106
|
+
* @return {Array[]} A 2-dimensional array of tuples: [ "group", "translated change" ].
|
|
109
107
|
*/
|
|
110
108
|
function getGlobalStylesChangelist(next, previous) {
|
|
111
109
|
const cacheKey = JSON.stringify({
|
|
@@ -149,11 +147,11 @@ function getGlobalStylesChangelist(next, previous) {
|
|
|
149
147
|
const result = [...new Set(changedValueTree)]
|
|
150
148
|
/*
|
|
151
149
|
* Translate the keys.
|
|
152
|
-
* Remove
|
|
150
|
+
* Remove empty translations.
|
|
153
151
|
*/.reduce((acc, curr) => {
|
|
154
152
|
const translation = getTranslation(curr);
|
|
155
|
-
if (translation
|
|
156
|
-
acc.push(translation);
|
|
153
|
+
if (translation) {
|
|
154
|
+
acc.push([curr.split('.')[0], translation]);
|
|
157
155
|
}
|
|
158
156
|
return acc;
|
|
159
157
|
}, []);
|
|
@@ -162,29 +160,68 @@ function getGlobalStylesChangelist(next, previous) {
|
|
|
162
160
|
}
|
|
163
161
|
|
|
164
162
|
/**
|
|
165
|
-
* From a getGlobalStylesChangelist() result, returns
|
|
166
|
-
*
|
|
163
|
+
* From a getGlobalStylesChangelist() result, returns an array of translated global styles changes, grouped by type.
|
|
164
|
+
* The types are 'blocks', 'elements', 'settings', and 'styles'.
|
|
167
165
|
*
|
|
168
166
|
* @param {Object} next The changed object to compare.
|
|
169
167
|
* @param {Object} previous The original object to compare against.
|
|
170
168
|
* @param {{maxResults:number}} options Options. maxResults: results to return before truncating.
|
|
171
|
-
* @return {string[]}
|
|
169
|
+
* @return {string[]} An array of translated changes.
|
|
172
170
|
*/
|
|
173
171
|
function getGlobalStylesChanges(next, previous, options = {}) {
|
|
174
|
-
|
|
175
|
-
const changesLength =
|
|
172
|
+
let changeList = getGlobalStylesChangelist(next, previous);
|
|
173
|
+
const changesLength = changeList.length;
|
|
176
174
|
const {
|
|
177
175
|
maxResults
|
|
178
176
|
} = options;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
if (changesLength) {
|
|
178
|
+
// Truncate to `n` results if necessary.
|
|
179
|
+
if (!!maxResults && changesLength > maxResults) {
|
|
180
|
+
changeList = changeList.slice(0, maxResults);
|
|
181
|
+
}
|
|
182
|
+
return Object.entries(changeList.reduce((acc, curr) => {
|
|
183
|
+
const group = acc[curr[0]] || [];
|
|
184
|
+
if (!group.includes(curr[1])) {
|
|
185
|
+
acc[curr[0]] = [...group, curr[1]];
|
|
186
|
+
}
|
|
187
|
+
return acc;
|
|
188
|
+
}, {})).map(([key, changeValues]) => {
|
|
189
|
+
const changeValuesLength = changeValues.length;
|
|
190
|
+
const joinedChangesValue = changeValues.join((0, _i18n.__)(', '));
|
|
191
|
+
switch (key) {
|
|
192
|
+
case 'blocks':
|
|
193
|
+
{
|
|
194
|
+
return (0, _i18n.sprintf)(
|
|
195
|
+
// translators: %s: a list of block names separated by a comma.
|
|
196
|
+
(0, _i18n._n)('%s block.', '%s blocks.', changeValuesLength), joinedChangesValue);
|
|
197
|
+
}
|
|
198
|
+
case 'elements':
|
|
199
|
+
{
|
|
200
|
+
return (0, _i18n.sprintf)(
|
|
201
|
+
// translators: %s: a list of element names separated by a comma.
|
|
202
|
+
(0, _i18n._n)('%s element.', '%s elements.', changeValuesLength), joinedChangesValue);
|
|
203
|
+
}
|
|
204
|
+
case 'settings':
|
|
205
|
+
{
|
|
206
|
+
return (0, _i18n.sprintf)(
|
|
207
|
+
// translators: %s: a list of theme.json setting labels separated by a comma.
|
|
208
|
+
(0, _i18n.__)('%s settings.'), joinedChangesValue);
|
|
209
|
+
}
|
|
210
|
+
case 'styles':
|
|
211
|
+
{
|
|
212
|
+
return (0, _i18n.sprintf)(
|
|
213
|
+
// translators: %s: a list of theme.json top-level styles labels separated by a comma.
|
|
214
|
+
(0, _i18n.__)('%s styles.'), joinedChangesValue);
|
|
215
|
+
}
|
|
216
|
+
default:
|
|
217
|
+
{
|
|
218
|
+
return (0, _i18n.sprintf)(
|
|
219
|
+
// translators: %s: a list of global styles changes separated by a comma.
|
|
220
|
+
(0, _i18n.__)('%s.'), joinedChangesValue);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
187
224
|
}
|
|
188
|
-
return
|
|
225
|
+
return EMPTY_ARRAY;
|
|
189
226
|
}
|
|
190
227
|
//# sourceMappingURL=get-global-styles-changes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_memize","_interopRequireDefault","require","_i18n","_blocks","globalStylesChangesCache","Map","EMPTY_ARRAY","translationMap","caption","__","link","button","heading","h1","h2","h3","h4","h5","h6","getBlockNames","memoize","getBlockTypes","reduce","accumulator","name","title","isObject","obj","getTranslation","key","keyArray","split","blockName","elementName","sprintf","undefined","deepCompare","changedObject","originalObject","parentPath","slice","join","allKeys","Set","Object","keys","diffs","path","changedPath","concat","getGlobalStylesChangelist","next","previous","cacheKey","JSON","stringify","has","get","changedValueTree","styles","color","typography","spacing","blocks","elements","settings","length","set","result","acc","curr","translation","includes","push","getGlobalStylesChanges","options","changes","changesLength","maxResults","deleteCount","andMoreText","_n","splice"],"sources":["@wordpress/block-editor/src/components/global-styles/get-global-styles-changes.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { getBlockTypes } from '@wordpress/blocks';\n\nconst globalStylesChangesCache = new Map();\nconst EMPTY_ARRAY = [];\nconst translationMap = {\n\tcaption: __( 'Caption' ),\n\tlink: __( 'Link' ),\n\tbutton: __( 'Button' ),\n\theading: __( 'Heading' ),\n\th1: __( 'H1' ),\n\th2: __( 'H2' ),\n\th3: __( 'H3' ),\n\th4: __( 'H4' ),\n\th5: __( 'H5' ),\n\th6: __( 'H6' ),\n\t'settings.color': __( 'Color settings' ),\n\t'settings.typography': __( 'Typography settings' ),\n\t'styles.color': __( 'Colors' ),\n\t'styles.spacing': __( 'Spacing' ),\n\t'styles.typography': __( 'Typography' ),\n};\nconst getBlockNames = memoize( () =>\n\tgetBlockTypes().reduce( ( accumulator, { name, title } ) => {\n\t\taccumulator[ name ] = title;\n\t\treturn accumulator;\n\t}, {} )\n);\nconst isObject = ( obj ) => obj !== null && typeof obj === 'object';\n\n/**\n * Get the translation for a given global styles key.\n * @param {string} key A key representing a path to a global style property or setting.\n * @return {string|undefined} A translated key or undefined if no translation exists.\n */\nfunction getTranslation( key ) {\n\tif ( translationMap[ key ] ) {\n\t\treturn translationMap[ key ];\n\t}\n\n\tconst keyArray = key.split( '.' );\n\n\tif ( keyArray?.[ 0 ] === 'blocks' ) {\n\t\tconst blockName = getBlockNames()?.[ keyArray[ 1 ] ];\n\t\treturn blockName || keyArray[ 1 ];\n\t}\n\n\tif ( keyArray?.[ 0 ] === 'elements' ) {\n\t\tconst elementName = translationMap[ keyArray[ 1 ] ] || keyArray[ 1 ];\n\t\treturn sprintf(\n\t\t\t// translators: %s: element name, e.g., heading button, link, caption.\n\t\t\t__( '%s element' ),\n\t\t\telementName\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * A deep comparison of two objects, optimized for comparing global styles.\n * @param {Object} changedObject The changed object to compare.\n * @param {Object} originalObject The original object to compare against.\n * @param {string} parentPath A key/value pair object of block names and their rendered titles.\n * @return {string[]} An array of paths whose values have changed.\n */\nfunction deepCompare( changedObject, originalObject, parentPath = '' ) {\n\t// We have two non-object values to compare.\n\tif ( ! isObject( changedObject ) && ! isObject( originalObject ) ) {\n\t\t/*\n\t\t * Only return a path if the value has changed.\n\t\t * And then only the path name up to 2 levels deep.\n\t\t */\n\t\treturn changedObject !== originalObject\n\t\t\t? parentPath.split( '.' ).slice( 0, 2 ).join( '.' )\n\t\t\t: undefined;\n\t}\n\n\t// Enable comparison when an object doesn't have a corresponding property to compare.\n\tchangedObject = isObject( changedObject ) ? changedObject : {};\n\toriginalObject = isObject( originalObject ) ? originalObject : {};\n\n\tconst allKeys = new Set( [\n\t\t...Object.keys( changedObject ),\n\t\t...Object.keys( originalObject ),\n\t] );\n\n\tlet diffs = [];\n\tfor ( const key of allKeys ) {\n\t\tconst path = parentPath ? parentPath + '.' + key : key;\n\t\tconst changedPath = deepCompare(\n\t\t\tchangedObject[ key ],\n\t\t\toriginalObject[ key ],\n\t\t\tpath\n\t\t);\n\t\tif ( changedPath ) {\n\t\t\tdiffs = diffs.concat( changedPath );\n\t\t}\n\t}\n\treturn diffs;\n}\n\n/**\n * Returns an array of translated summarized global styles changes.\n * Results are cached using a Map() key of `JSON.stringify( { next, previous } )`.\n *\n * @param {Object} next The changed object to compare.\n * @param {Object} previous The original object to compare against.\n * @return {string[]} An array of translated changes.\n */\nfunction getGlobalStylesChangelist( next, previous ) {\n\tconst cacheKey = JSON.stringify( { next, previous } );\n\n\tif ( globalStylesChangesCache.has( cacheKey ) ) {\n\t\treturn globalStylesChangesCache.get( cacheKey );\n\t}\n\n\t/*\n\t * Compare the two changesets with normalized keys.\n\t * The order of these keys determines the order in which\n\t * they'll appear in the results.\n\t */\n\tconst changedValueTree = deepCompare(\n\t\t{\n\t\t\tstyles: {\n\t\t\t\tcolor: next?.styles?.color,\n\t\t\t\ttypography: next?.styles?.typography,\n\t\t\t\tspacing: next?.styles?.spacing,\n\t\t\t},\n\t\t\tblocks: next?.styles?.blocks,\n\t\t\telements: next?.styles?.elements,\n\t\t\tsettings: next?.settings,\n\t\t},\n\t\t{\n\t\t\tstyles: {\n\t\t\t\tcolor: previous?.styles?.color,\n\t\t\t\ttypography: previous?.styles?.typography,\n\t\t\t\tspacing: previous?.styles?.spacing,\n\t\t\t},\n\t\t\tblocks: previous?.styles?.blocks,\n\t\t\telements: previous?.styles?.elements,\n\t\t\tsettings: previous?.settings,\n\t\t}\n\t);\n\n\tif ( ! changedValueTree.length ) {\n\t\tglobalStylesChangesCache.set( cacheKey, EMPTY_ARRAY );\n\t\treturn EMPTY_ARRAY;\n\t}\n\n\t// Remove duplicate results.\n\tconst result = [ ...new Set( changedValueTree ) ]\n\t\t/*\n\t\t * Translate the keys.\n\t\t * Remove duplicate or empty translations.\n\t\t */\n\t\t.reduce( ( acc, curr ) => {\n\t\t\tconst translation = getTranslation( curr );\n\t\t\tif ( translation && ! acc.includes( translation ) ) {\n\t\t\t\tacc.push( translation );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\tglobalStylesChangesCache.set( cacheKey, result );\n\n\treturn result;\n}\n\n/**\n * From a getGlobalStylesChangelist() result, returns a truncated array of translated changes.\n * Appends a translated string indicating the number of changes that were truncated.\n *\n * @param {Object} next The changed object to compare.\n * @param {Object} previous The original object to compare against.\n * @param {{maxResults:number}} options Options. maxResults: results to return before truncating.\n * @return {string[]} An array of translated changes.\n */\nexport default function getGlobalStylesChanges( next, previous, options = {} ) {\n\tconst changes = getGlobalStylesChangelist( next, previous );\n\tconst changesLength = changes.length;\n\tconst { maxResults } = options;\n\n\t// Truncate to `n` results if necessary.\n\tif ( !! maxResults && changesLength && changesLength > maxResults ) {\n\t\tconst deleteCount = changesLength - maxResults;\n\t\tconst andMoreText = sprintf(\n\t\t\t// translators: %d: number of global styles changes that are not displayed in the UI.\n\t\t\t_n( '…and %d more change', '…and %d more changes', deleteCount ),\n\t\t\tdeleteCount\n\t\t);\n\t\tchanges.splice( maxResults, deleteCount, andMoreText );\n\t}\n\n\treturn changes;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,MAAMG,wBAAwB,GAAG,IAAIC,GAAG,CAAC,CAAC;AAC1C,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,cAAc,GAAG;EACtBC,OAAO,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;EACxBC,IAAI,EAAE,IAAAD,QAAE,EAAE,MAAO,CAAC;EAClBE,MAAM,EAAE,IAAAF,QAAE,EAAE,QAAS,CAAC;EACtBG,OAAO,EAAE,IAAAH,QAAE,EAAE,SAAU,CAAC;EACxBI,EAAE,EAAE,IAAAJ,QAAE,EAAE,IAAK,CAAC;EACdK,EAAE,EAAE,IAAAL,QAAE,EAAE,IAAK,CAAC;EACdM,EAAE,EAAE,IAAAN,QAAE,EAAE,IAAK,CAAC;EACdO,EAAE,EAAE,IAAAP,QAAE,EAAE,IAAK,CAAC;EACdQ,EAAE,EAAE,IAAAR,QAAE,EAAE,IAAK,CAAC;EACdS,EAAE,EAAE,IAAAT,QAAE,EAAE,IAAK,CAAC;EACd,gBAAgB,EAAE,IAAAA,QAAE,EAAE,gBAAiB,CAAC;EACxC,qBAAqB,EAAE,IAAAA,QAAE,EAAE,qBAAsB,CAAC;EAClD,cAAc,EAAE,IAAAA,QAAE,EAAE,QAAS,CAAC;EAC9B,gBAAgB,EAAE,IAAAA,QAAE,EAAE,SAAU,CAAC;EACjC,mBAAmB,EAAE,IAAAA,QAAE,EAAE,YAAa;AACvC,CAAC;AACD,MAAMU,aAAa,GAAG,IAAAC,eAAO,EAAE,MAC9B,IA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CAAC,EAAE,EAAG,CAAC;EAERjE,wBAAwB,CAAC+D,GAAG,CAAEd,QAAQ,EAAEe,MAAO,CAAC;EAEhD,OAAOA,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASM,sBAAsBA,CAAEvB,IAAI,EAAEC,QAAQ,EAAEuB,OAAO,GAAG,CAAC,CAAC,EAAG;EAC9E,MAAMC,OAAO,GAAG1B,yBAAyB,CAAEC,IAAI,EAAEC,QAAS,CAAC;EAC3D,MAAMyB,aAAa,GAAGD,OAAO,CAACV,MAAM;EACpC,MAAM;IAAEY;EAAW,CAAC,GAAGH,OAAO;;EAE9B;EACA,IAAK,CAAC,CAAEG,UAAU,IAAID,aAAa,IAAIA,aAAa,GAAGC,UAAU,EAAG;IACnE,MAAMC,WAAW,GAAGF,aAAa,GAAGC,UAAU;IAC9C,MAAME,WAAW,GAAG,IAAA9C,aAAO;IAC1B;IACA,IAAA+C,QAAE,EAAE,qBAAqB,EAAE,sBAAsB,EAAEF,WAAY,CAAC,EAChEA,WACD,CAAC;IACDH,OAAO,CAACM,MAAM,CAAEJ,UAAU,EAAEC,WAAW,EAAEC,WAAY,CAAC;EACvD;EAEA,OAAOJ,OAAO;AACf"}
|
|
1
|
+
{"version":3,"names":["_memize","_interopRequireDefault","require","_i18n","_blocks","globalStylesChangesCache","Map","EMPTY_ARRAY","translationMap","caption","__","link","button","heading","h1","h2","h3","h4","h5","h6","getBlockNames","memoize","getBlockTypes","reduce","accumulator","name","title","isObject","obj","getTranslation","key","keyArray","split","blockName","undefined","deepCompare","changedObject","originalObject","parentPath","slice","join","allKeys","Set","Object","keys","diffs","path","changedPath","concat","getGlobalStylesChangelist","next","previous","cacheKey","JSON","stringify","has","get","changedValueTree","styles","color","typography","spacing","blocks","elements","settings","length","set","result","acc","curr","translation","push","getGlobalStylesChanges","options","changeList","changesLength","maxResults","entries","group","includes","map","changeValues","changeValuesLength","joinedChangesValue","sprintf","_n"],"sources":["@wordpress/block-editor/src/components/global-styles/get-global-styles-changes.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { getBlockTypes } from '@wordpress/blocks';\n\nconst globalStylesChangesCache = new Map();\nconst EMPTY_ARRAY = [];\nconst translationMap = {\n\tcaption: __( 'Caption' ),\n\tlink: __( 'Link' ),\n\tbutton: __( 'Button' ),\n\theading: __( 'Heading' ),\n\th1: __( 'H1' ),\n\th2: __( 'H2' ),\n\th3: __( 'H3' ),\n\th4: __( 'H4' ),\n\th5: __( 'H5' ),\n\th6: __( 'H6' ),\n\t'settings.color': __( 'Color' ),\n\t'settings.typography': __( 'Typography' ),\n\t'styles.color': __( 'Colors' ),\n\t'styles.spacing': __( 'Spacing' ),\n\t'styles.typography': __( 'Typography' ),\n};\nconst getBlockNames = memoize( () =>\n\tgetBlockTypes().reduce( ( accumulator, { name, title } ) => {\n\t\taccumulator[ name ] = title;\n\t\treturn accumulator;\n\t}, {} )\n);\nconst isObject = ( obj ) => obj !== null && typeof obj === 'object';\n\n/**\n * Get the translation for a given global styles key.\n * @param {string} key A key representing a path to a global style property or setting.\n * @return {string|undefined} A translated key or undefined if no translation exists.\n */\nfunction getTranslation( key ) {\n\tif ( translationMap[ key ] ) {\n\t\treturn translationMap[ key ];\n\t}\n\n\tconst keyArray = key.split( '.' );\n\n\tif ( keyArray?.[ 0 ] === 'blocks' ) {\n\t\tconst blockName = getBlockNames()?.[ keyArray[ 1 ] ];\n\t\treturn blockName || keyArray[ 1 ];\n\t}\n\n\tif ( keyArray?.[ 0 ] === 'elements' ) {\n\t\treturn translationMap[ keyArray[ 1 ] ] || keyArray[ 1 ];\n\t}\n\n\treturn undefined;\n}\n\n/**\n * A deep comparison of two objects, optimized for comparing global styles.\n * @param {Object} changedObject The changed object to compare.\n * @param {Object} originalObject The original object to compare against.\n * @param {string} parentPath A key/value pair object of block names and their rendered titles.\n * @return {string[]} An array of paths whose values have changed.\n */\nfunction deepCompare( changedObject, originalObject, parentPath = '' ) {\n\t// We have two non-object values to compare.\n\tif ( ! isObject( changedObject ) && ! isObject( originalObject ) ) {\n\t\t/*\n\t\t * Only return a path if the value has changed.\n\t\t * And then only the path name up to 2 levels deep.\n\t\t */\n\t\treturn changedObject !== originalObject\n\t\t\t? parentPath.split( '.' ).slice( 0, 2 ).join( '.' )\n\t\t\t: undefined;\n\t}\n\n\t// Enable comparison when an object doesn't have a corresponding property to compare.\n\tchangedObject = isObject( changedObject ) ? changedObject : {};\n\toriginalObject = isObject( originalObject ) ? originalObject : {};\n\n\tconst allKeys = new Set( [\n\t\t...Object.keys( changedObject ),\n\t\t...Object.keys( originalObject ),\n\t] );\n\n\tlet diffs = [];\n\tfor ( const key of allKeys ) {\n\t\tconst path = parentPath ? parentPath + '.' + key : key;\n\t\tconst changedPath = deepCompare(\n\t\t\tchangedObject[ key ],\n\t\t\toriginalObject[ key ],\n\t\t\tpath\n\t\t);\n\t\tif ( changedPath ) {\n\t\t\tdiffs = diffs.concat( changedPath );\n\t\t}\n\t}\n\treturn diffs;\n}\n\n/**\n * Returns an array of translated summarized global styles changes.\n * Results are cached using a Map() key of `JSON.stringify( { next, previous } )`.\n *\n * @param {Object} next The changed object to compare.\n * @param {Object} previous The original object to compare against.\n * @return {Array[]} A 2-dimensional array of tuples: [ \"group\", \"translated change\" ].\n */\nexport function getGlobalStylesChangelist( next, previous ) {\n\tconst cacheKey = JSON.stringify( { next, previous } );\n\n\tif ( globalStylesChangesCache.has( cacheKey ) ) {\n\t\treturn globalStylesChangesCache.get( cacheKey );\n\t}\n\n\t/*\n\t * Compare the two changesets with normalized keys.\n\t * The order of these keys determines the order in which\n\t * they'll appear in the results.\n\t */\n\tconst changedValueTree = deepCompare(\n\t\t{\n\t\t\tstyles: {\n\t\t\t\tcolor: next?.styles?.color,\n\t\t\t\ttypography: next?.styles?.typography,\n\t\t\t\tspacing: next?.styles?.spacing,\n\t\t\t},\n\t\t\tblocks: next?.styles?.blocks,\n\t\t\telements: next?.styles?.elements,\n\t\t\tsettings: next?.settings,\n\t\t},\n\t\t{\n\t\t\tstyles: {\n\t\t\t\tcolor: previous?.styles?.color,\n\t\t\t\ttypography: previous?.styles?.typography,\n\t\t\t\tspacing: previous?.styles?.spacing,\n\t\t\t},\n\t\t\tblocks: previous?.styles?.blocks,\n\t\t\telements: previous?.styles?.elements,\n\t\t\tsettings: previous?.settings,\n\t\t}\n\t);\n\n\tif ( ! changedValueTree.length ) {\n\t\tglobalStylesChangesCache.set( cacheKey, EMPTY_ARRAY );\n\t\treturn EMPTY_ARRAY;\n\t}\n\n\t// Remove duplicate results.\n\tconst result = [ ...new Set( changedValueTree ) ]\n\t\t/*\n\t\t * Translate the keys.\n\t\t * Remove empty translations.\n\t\t */\n\t\t.reduce( ( acc, curr ) => {\n\t\t\tconst translation = getTranslation( curr );\n\t\t\tif ( translation ) {\n\t\t\t\tacc.push( [ curr.split( '.' )[ 0 ], translation ] );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\tglobalStylesChangesCache.set( cacheKey, result );\n\n\treturn result;\n}\n\n/**\n * From a getGlobalStylesChangelist() result, returns an array of translated global styles changes, grouped by type.\n * The types are 'blocks', 'elements', 'settings', and 'styles'.\n *\n * @param {Object} next The changed object to compare.\n * @param {Object} previous The original object to compare against.\n * @param {{maxResults:number}} options Options. maxResults: results to return before truncating.\n * @return {string[]} An array of translated changes.\n */\nexport default function getGlobalStylesChanges( next, previous, options = {} ) {\n\tlet changeList = getGlobalStylesChangelist( next, previous );\n\tconst changesLength = changeList.length;\n\tconst { maxResults } = options;\n\n\tif ( changesLength ) {\n\t\t// Truncate to `n` results if necessary.\n\t\tif ( !! maxResults && changesLength > maxResults ) {\n\t\t\tchangeList = changeList.slice( 0, maxResults );\n\t\t}\n\t\treturn Object.entries(\n\t\t\tchangeList.reduce( ( acc, curr ) => {\n\t\t\t\tconst group = acc[ curr[ 0 ] ] || [];\n\t\t\t\tif ( ! group.includes( curr[ 1 ] ) ) {\n\t\t\t\t\tacc[ curr[ 0 ] ] = [ ...group, curr[ 1 ] ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t}, {} )\n\t\t).map( ( [ key, changeValues ] ) => {\n\t\t\tconst changeValuesLength = changeValues.length;\n\t\t\tconst joinedChangesValue = changeValues.join( __( ', ' ) );\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t// translators: %s: a list of block names separated by a comma.\n\t\t\t\t\t\t_n( '%s block.', '%s blocks.', changeValuesLength ),\n\t\t\t\t\t\tjoinedChangesValue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase 'elements': {\n\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t// translators: %s: a list of element names separated by a comma.\n\t\t\t\t\t\t_n( '%s element.', '%s elements.', changeValuesLength ),\n\t\t\t\t\t\tjoinedChangesValue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase 'settings': {\n\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t// translators: %s: a list of theme.json setting labels separated by a comma.\n\t\t\t\t\t\t__( '%s settings.' ),\n\t\t\t\t\t\tjoinedChangesValue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase 'styles': {\n\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t// translators: %s: a list of theme.json top-level styles labels separated by a comma.\n\t\t\t\t\t\t__( '%s styles.' ),\n\t\t\t\t\t\tjoinedChangesValue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t// translators: %s: a list of global styles changes separated by a comma.\n\t\t\t\t\t\t__( '%s.' ),\n\t\t\t\t\t\tjoinedChangesValue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn EMPTY_ARRAY;\n}\n"],"mapp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AAE,EAAE,aAAa,EAAE,cAAc,EAAEH,kBAAmB,CAAC,EACvDC,kBACD,CAAC;UACF;QACA,KAAK,UAAU;UAAE;YAChB,OAAO,IAAAC,aAAO;YACb;YACA,IAAA1E,QAAE,EAAE,cAAe,CAAC,EACpByE,kBACD,CAAC;UACF;QACA,KAAK,QAAQ;UAAE;YACd,OAAO,IAAAC,aAAO;YACb;YACA,IAAA1E,QAAE,EAAE,YAAa,CAAC,EAClByE,kBACD,CAAC;UACF;QACA;UAAS;YACR,OAAO,IAAAC,aAAO;YACb;YACA,IAAA1E,QAAE,EAAE,KAAM,CAAC,EACXyE,kBACD,CAAC;UACF;MACD;IACD,CAAE,CAAC;EACJ;EAEA,OAAO5E,WAAW;AACnB"}
|
|
@@ -26,10 +26,10 @@ function ShadowPopoverContainer({
|
|
|
26
26
|
onShadowChange,
|
|
27
27
|
settings
|
|
28
28
|
}) {
|
|
29
|
-
const defaultShadows = settings?.shadow?.presets?.default;
|
|
30
|
-
const themeShadows = settings?.shadow?.presets?.theme;
|
|
29
|
+
const defaultShadows = settings?.shadow?.presets?.default || [];
|
|
30
|
+
const themeShadows = settings?.shadow?.presets?.theme || [];
|
|
31
31
|
const defaultPresetsEnabled = settings?.shadow?.defaultPresets;
|
|
32
|
-
const shadows = [...(defaultPresetsEnabled ? defaultShadows : []), ...
|
|
32
|
+
const shadows = [...(defaultPresetsEnabled ? defaultShadows : []), ...themeShadows];
|
|
33
33
|
return (0, _react.createElement)("div", {
|
|
34
34
|
className: "block-editor-global-styles__shadow-popover-container"
|
|
35
35
|
}, (0, _react.createElement)(_components.__experimentalVStack, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_icons","_classnames","_interopRequireDefault","ShadowPopoverContainer","shadow","onShadowChange","settings","defaultShadows","presets","default","themeShadows","theme","defaultPresetsEnabled","defaultPresets","shadows","_react","createElement","className","__experimentalVStack","spacing","__experimentalHeading","level","__","ShadowPresets","activeShadow","onSelect","__experimentalGrid","columns","gap","align","justify","map","name","slug","ShadowIndicator","key","label","isActive","undefined","Button","onClick","style","boxShadow","showTooltip","Icon","icon","check","ShadowPopover","popoverProps","placement","offset","shift","Dropdown","renderToggle","renderShadowToggle","renderContent","__experimentalDropdownContentWrapper","paddingSize","onToggle","isOpen","toggleProps","classNames","__experimentalHStack","shadowIcon","size","FlexItem"],"sources":["@wordpress/block-editor/src/components/global-styles/shadow-panel-components.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalGrid as Grid,\n\t__experimentalHStack as HStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tButton,\n\tFlexItem,\n\tDropdown,\n} from '@wordpress/components';\nimport { shadow as shadowIcon, Icon, check } from '@wordpress/icons';\n/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\nexport function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {\n\tconst defaultShadows = settings?.shadow?.presets?.default;\n\tconst themeShadows = settings?.shadow?.presets?.theme;\n\tconst defaultPresetsEnabled = settings?.shadow?.defaultPresets;\n\n\tconst shadows = [\n\t\t...( defaultPresetsEnabled ? defaultShadows : [] ),\n\t\t...
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_icons","_classnames","_interopRequireDefault","ShadowPopoverContainer","shadow","onShadowChange","settings","defaultShadows","presets","default","themeShadows","theme","defaultPresetsEnabled","defaultPresets","shadows","_react","createElement","className","__experimentalVStack","spacing","__experimentalHeading","level","__","ShadowPresets","activeShadow","onSelect","__experimentalGrid","columns","gap","align","justify","map","name","slug","ShadowIndicator","key","label","isActive","undefined","Button","onClick","style","boxShadow","showTooltip","Icon","icon","check","ShadowPopover","popoverProps","placement","offset","shift","Dropdown","renderToggle","renderShadowToggle","renderContent","__experimentalDropdownContentWrapper","paddingSize","onToggle","isOpen","toggleProps","classNames","__experimentalHStack","shadowIcon","size","FlexItem"],"sources":["@wordpress/block-editor/src/components/global-styles/shadow-panel-components.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalGrid as Grid,\n\t__experimentalHStack as HStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tButton,\n\tFlexItem,\n\tDropdown,\n} from '@wordpress/components';\nimport { shadow as shadowIcon, Icon, check } from '@wordpress/icons';\n/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\nexport function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {\n\tconst defaultShadows = settings?.shadow?.presets?.default || [];\n\tconst themeShadows = settings?.shadow?.presets?.theme || [];\n\tconst defaultPresetsEnabled = settings?.shadow?.defaultPresets;\n\n\tconst shadows = [\n\t\t...( defaultPresetsEnabled ? defaultShadows : [] ),\n\t\t...themeShadows,\n\t];\n\n\treturn (\n\t\t<div className=\"block-editor-global-styles__shadow-popover-container\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<Heading level={ 5 }>{ __( 'Drop shadow' ) }</Heading>\n\t\t\t\t<ShadowPresets\n\t\t\t\t\tpresets={ shadows }\n\t\t\t\t\tactiveShadow={ shadow }\n\t\t\t\t\tonSelect={ onShadowChange }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport function ShadowPresets( { presets, activeShadow, onSelect } ) {\n\treturn ! presets ? null : (\n\t\t<Grid columns={ 6 } gap={ 0 } align=\"center\" justify=\"center\">\n\t\t\t{ presets.map( ( { name, slug, shadow } ) => (\n\t\t\t\t<ShadowIndicator\n\t\t\t\t\tkey={ slug }\n\t\t\t\t\tlabel={ name }\n\t\t\t\t\tisActive={ shadow === activeShadow }\n\t\t\t\t\tonSelect={ () =>\n\t\t\t\t\t\tonSelect( shadow === activeShadow ? undefined : shadow )\n\t\t\t\t\t}\n\t\t\t\t\tshadow={ shadow }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Grid>\n\t);\n}\n\nexport function ShadowIndicator( { label, isActive, onSelect, shadow } ) {\n\treturn (\n\t\t<div className=\"block-editor-global-styles__shadow-indicator-wrapper\">\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-global-styles__shadow-indicator\"\n\t\t\t\tonClick={ onSelect }\n\t\t\t\tlabel={ label }\n\t\t\t\tstyle={ { boxShadow: shadow } }\n\t\t\t\tshowTooltip\n\t\t\t>\n\t\t\t\t{ isActive && <Icon icon={ check } /> }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport function ShadowPopover( { shadow, onShadowChange, settings } ) {\n\tconst popoverProps = {\n\t\tplacement: 'left-start',\n\t\toffset: 36,\n\t\tshift: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tclassName=\"block-editor-global-styles__shadow-dropdown\"\n\t\t\trenderToggle={ renderShadowToggle() }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t\t<ShadowPopoverContainer\n\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\tonShadowChange={ onShadowChange }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nfunction renderShadowToggle() {\n\treturn ( { onToggle, isOpen } ) => {\n\t\tconst toggleProps = {\n\t\t\tonClick: onToggle,\n\t\t\tclassName: classNames( { 'is-open': isOpen } ),\n\t\t\t'aria-expanded': isOpen,\n\t\t};\n\n\t\treturn (\n\t\t\t<Button { ...toggleProps }>\n\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"block-editor-global-styles__toggle-icon\"\n\t\t\t\t\t\ticon={ shadowIcon }\n\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t\t<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ographyPanel(settings) {
|
|
|
43
43
|
return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || hasTextTransform || hasFontSize || hasTextDecoration || hasWritingMode || hasTextColumns;
|
|
44
44
|
}
|
|
45
45
|
function useHasFontSizeControl(settings) {
|
|
46
|
-
return (0, _getBlockSettings.
|
|
46
|
+
return (0, _getBlockSettings.hasOriginValue)(settings?.typography?.fontSizes) || settings?.typography?.customFontSize;
|
|
47
47
|
}
|
|
48
48
|
function useHasFontFamilyControl(settings) {
|
|
49
|
-
return (0, _getBlockSettings.
|
|
49
|
+
return (0, _getBlockSettings.hasOriginValue)(settings?.typography?.fontFamilies);
|
|
50
50
|
}
|
|
51
51
|
function useHasLineHeightControl(settings) {
|
|
52
52
|
return settings?.typography?.lineHeight;
|
|
@@ -79,10 +79,11 @@ function useHasTextColumnsControl(settings) {
|
|
|
79
79
|
return settings?.typography?.textColumns;
|
|
80
80
|
}
|
|
81
81
|
function getUniqueFontSizesBySlug(settings) {
|
|
82
|
-
|
|
83
|
-
const
|
|
82
|
+
var _settings$typography$, _overrideOrigins;
|
|
83
|
+
const fontSizes = (_settings$typography$ = settings?.typography?.fontSizes) !== null && _settings$typography$ !== void 0 ? _settings$typography$ : {};
|
|
84
|
+
const overriddenFontSizes = (_overrideOrigins = (0, _getBlockSettings.overrideOrigins)(fontSizes)) !== null && _overrideOrigins !== void 0 ? _overrideOrigins : [];
|
|
84
85
|
const uniqueSizes = [];
|
|
85
|
-
for (const currentSize of
|
|
86
|
+
for (const currentSize of overriddenFontSizes) {
|
|
86
87
|
if (!uniqueSizes.some(({
|
|
87
88
|
slug
|
|
88
89
|
}) => slug === currentSize.slug)) {
|
|
@@ -129,13 +130,14 @@ function TypographyPanel({
|
|
|
129
130
|
panelId,
|
|
130
131
|
defaultControls = DEFAULT_CONTROLS
|
|
131
132
|
}) {
|
|
133
|
+
var _settings$typography$2;
|
|
132
134
|
const decodeValue = rawValue => (0, _utils.getValueFromVariable)({
|
|
133
135
|
settings
|
|
134
136
|
}, '', rawValue);
|
|
135
137
|
|
|
136
138
|
// Font Family
|
|
137
139
|
const hasFontFamilyEnabled = useHasFontFamilyControl(settings);
|
|
138
|
-
const fontFamilies = settings?.typography?.fontFamilies;
|
|
140
|
+
const fontFamilies = (_settings$typography$2 = settings?.typography?.fontFamilies) !== null && _settings$typography$2 !== void 0 ? _settings$typography$2 : {};
|
|
139
141
|
const mergedFontFamilies = fontFamilies ? (0, _getBlockSettings.mergeOrigins)(fontFamilies) : [];
|
|
140
142
|
const fontFamily = decodeValue(inheritedValue?.typography?.fontFamily);
|
|
141
143
|
const setFontFamily = newValue => {
|