@wordpress/block-editor 12.21.0 → 12.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-actions/index.js +2 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.js +5 -5
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-list/block-crash-boundary.native.js +49 -0
- package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build/components/block-list/block-crash-warning.native.js +24 -0
- package/build/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build/components/block-list/block.native.js +7 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +29 -29
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +3 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +1 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/child-layout-control/index.js +108 -11
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +11 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +8 -33
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +34 -30
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/menu.js +3 -9
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/search-results.js +2 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build/components/list-view/block-select-button.js +2 -12
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +4 -11
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/utils.js +5 -3
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +4 -0
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/warning/index.native.js +9 -4
- package/build/components/warning/index.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -8
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +39 -2
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/index.js +2 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +28 -6
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +21 -10
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/private-apis.native.js +3 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/reducer.js +31 -26
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/block-actions/index.js +2 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +5 -5
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
- package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build-module/components/block-list/block-crash-warning.native.js +15 -0
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build-module/components/block-list/block.native.js +7 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +3 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +30 -30
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +3 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +1 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +109 -12
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -34
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +0 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +34 -30
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/menu.js +3 -9
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build-module/components/list-view/block-select-button.js +3 -13
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/utils.js +2 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +4 -0
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +9 -4
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/hooks/anchor.js +8 -9
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +38 -1
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +28 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +21 -10
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/private-apis.native.js +3 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/reducer.js +31 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/content-rtl.css +14 -0
- package/build-style/content.css +14 -0
- package/build-style/style-rtl.css +8 -20
- package/build-style/style.css +8 -20
- package/package.json +31 -31
- package/src/components/block-actions/index.js +2 -8
- package/src/components/block-bindings-toolbar-indicator/style.scss +10 -8
- package/src/components/block-heading-level-dropdown/README.md +5 -5
- package/src/components/block-heading-level-dropdown/index.js +5 -5
- package/src/components/block-heading-level-dropdown/index.native.js +5 -4
- package/src/components/block-list/block-crash-boundary.native.js +43 -0
- package/src/components/block-list/block-crash-warning.native.js +19 -0
- package/src/components/block-list/block.native.js +14 -7
- package/src/components/block-list/content.scss +16 -0
- package/src/components/block-settings/container.native.js +5 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +41 -56
- package/src/components/block-settings-menu-controls/README.md +0 -9
- package/src/components/block-settings-menu-controls/index.js +1 -6
- package/src/components/block-toolbar/index.js +3 -1
- package/src/components/block-toolbar/shuffle.js +1 -1
- package/src/components/block-toolbar/test/index.native.js +1 -7
- package/src/components/child-layout-control/index.js +147 -35
- package/src/components/convert-to-group-buttons/toolbar.js +13 -1
- package/src/components/global-styles/dimensions-panel.js +9 -34
- package/src/components/global-styles/test/use-global-styles-output.js +31 -0
- package/src/components/global-styles/use-global-styles-output.js +3 -1
- package/src/components/global-styles/utils.js +0 -18
- package/src/components/iframe/index.js +60 -44
- package/src/components/inserter/block-patterns-explorer/index.js +2 -9
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/inserter/menu.js +4 -10
- package/src/components/inserter/mobile-tab-navigation.js +1 -1
- package/src/components/inserter/search-results.js +1 -2
- package/src/components/inserter/tabs.js +1 -2
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
- package/src/components/link-control/style.scss +0 -5
- package/src/components/list-view/block-select-button.js +2 -18
- package/src/components/list-view/block.js +12 -21
- package/src/components/list-view/style.scss +34 -24
- package/src/components/list-view/utils.js +4 -1
- package/src/components/rich-text/README.md +6 -0
- package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/src/components/use-moving-animation/index.js +1 -0
- package/src/components/warning/index.native.js +19 -15
- package/src/hooks/anchor.js +41 -61
- package/src/hooks/background.js +48 -3
- package/src/hooks/index.js +2 -0
- package/src/hooks/layout-child.js +44 -8
- package/src/hooks/layout.js +22 -18
- package/src/hooks/position.js +1 -1
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
- package/src/hooks/test/anchor.native.js +32 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/reducer.js +41 -41
- package/tsconfig.json +1 -0
- package/build/utils/calculate-scale.js +0 -17
- package/build/utils/calculate-scale.js.map +0 -1
- package/build-module/utils/calculate-scale.js +0 -11
- package/build-module/utils/calculate-scale.js.map +0 -1
- package/src/utils/calculate-scale.js +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DropdownMenu","Icon","MenuGroup","MenuItem","check","getSupportedMenuItems","VIEWS","checkIcon","createElement","icon","size","SidesDropdown","label","labelProp","onChange","sides","value","length","supportedItems","sideIcon","custom","customItem","menuItems","className","toggleProps","
|
|
1
|
+
{"version":3,"names":["DropdownMenu","Icon","MenuGroup","MenuItem","check","getSupportedMenuItems","VIEWS","checkIcon","createElement","icon","size","SidesDropdown","label","labelProp","onChange","sides","value","length","supportedItems","sideIcon","custom","customItem","menuItems","className","toggleProps","onClose","Fragment","Object","entries","map","slug","isSelected","key","iconPosition","role","onClick","suffix","undefined"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/sides-dropdown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, Icon, MenuGroup, MenuItem } from '@wordpress/components';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedMenuItems, VIEWS } from '../utils';\n\nconst checkIcon = <Icon icon={ check } size={ 24 } />;\n\nexport default function SidesDropdown( {\n\tlabel: labelProp,\n\tonChange,\n\tsides,\n\tvalue,\n} ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn;\n\t}\n\n\tconst supportedItems = getSupportedMenuItems( sides );\n\tconst sideIcon = supportedItems[ value ].icon;\n\tconst { custom: customItem, ...menuItems } = supportedItems;\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ sideIcon }\n\t\t\tlabel={ labelProp }\n\t\t\tclassName=\"spacing-sizes-control__dropdown\"\n\t\t\ttoggleProps={ { size: 'small' } }\n\t\t>\n\t\t\t{ ( { onClose } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ Object.entries( menuItems ).map(\n\t\t\t\t\t\t\t\t( [ slug, { label, icon } ] ) => {\n\t\t\t\t\t\t\t\t\tconst isSelected = value === slug;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonChange( slug );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tsuffix={\n\t\t\t\t\t\t\t\t\t\t\t\tisSelected\n\t\t\t\t\t\t\t\t\t\t\t\t\t? checkIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t{ !! customItem && (\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customItem.icon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tisSelected={ value === VIEWS.custom }\n\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChange( VIEWS.custom );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsuffix={\n\t\t\t\t\t\t\t\t\t\tvalue === VIEWS.custom\n\t\t\t\t\t\t\t\t\t\t\t? checkIcon\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ customItem.label }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t} }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AAC/E,SAASC,KAAK,QAAQ,kBAAkB;;AAExC;AACA;AACA;AACA,SAASC,qBAAqB,EAAEC,KAAK,QAAQ,UAAU;AAEvD,MAAMC,SAAS,GAAGC,aAAA,CAACP,IAAI;EAACQ,IAAI,EAAGL,KAAO;EAACM,IAAI,EAAG;AAAI,CAAE,CAAC;AAErD,eAAe,SAASC,aAAaA,CAAE;EACtCC,KAAK,EAAEC,SAAS;EAChBC,QAAQ;EACRC,KAAK;EACLC;AACD,CAAC,EAAG;EACH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KAAK,CAACc,MAAQ;MACrCc,IAAI,EAAC,eAAe;MACpBC,OAAO,EAAGA,CAAA,KAAM;QACfrB,QAAQ,CAAER,KAAK,CAACc,MAAO,CAAC;QACxBK,OAAO,CAAC,CAAC;MACV,CAAG;MACHW,MAAM,EACLpB,KAAK,KAAKV,KAAK,CAACc,MAAM,GACnBb,SAAS,GACT8B;IACH,GAEChB,UAAU,CAACT,KACJ,CACA,CAEX,CAAC;EAEL,CACa,CAAC;AAEjB"}
|
|
@@ -142,6 +142,10 @@ function useMovingAnimation({
|
|
|
142
142
|
});
|
|
143
143
|
return () => {
|
|
144
144
|
controller.stop();
|
|
145
|
+
controller.set({
|
|
146
|
+
x: 0,
|
|
147
|
+
y: 0
|
|
148
|
+
});
|
|
145
149
|
};
|
|
146
150
|
}, [previous, prevRect, clientId, isTyping, getGlobalBlockCount, isBlockSelected, isFirstMultiSelectedBlock, isBlockMultiSelected, isAncestorMultiSelected]);
|
|
147
151
|
return ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Controller","useLayoutEffect","useMemo","useRef","getScrollContainer","useSelect","store","blockEditorStore","BLOCK_ANIMATION_THRESHOLD","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","triggerAnimationOnChange","clientId","ref","isTyping","getGlobalBlockCount","isBlockSelected","isFirstMultiSelectedBlock","isBlockMultiSelected","isAncestorMultiSelected","previous","prevRect","current","getBoundingClientRect","scrollContainer","isSelected","adjustScrolling","preserveScrollPosition","blockRect","diff","scrollTop","disableAnimation","window","matchMedia","matches","isPartOfSelection","zIndex","controller","x","y","config","mass","tension","friction","onChange","value","Math","round","finishedMoving","style","transformOrigin","transform","undefined","destination","start","from","stop"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Controller } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useRef } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\nfunction getAbsolutePosition( element ) {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n}\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n * @param {string} $1.clientId\n */\nfunction useMovingAnimation( { triggerAnimationOnChange, clientId } ) {\n\tconst ref = useRef();\n\tconst {\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t} = useSelect( blockEditorStore );\n\n\t// Whenever the trigger changes, we need to take a snapshot of the current\n\t// position of the block to use it as a destination point for the animation.\n\tconst { previous, prevRect } = useMemo(\n\t\t() => ( {\n\t\t\tprevious: ref.current && getAbsolutePosition( ref.current ),\n\t\t\tprevRect: ref.current && ref.current.getBoundingClientRect(),\n\t\t} ),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous || ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\t\tconst isSelected = isBlockSelected( clientId );\n\t\tconst adjustScrolling =\n\t\t\tisSelected || isFirstMultiSelectedBlock( clientId );\n\n\t\tfunction preserveScrollPosition() {\n\t\t\tif ( adjustScrolling && prevRect ) {\n\t\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\t\tif ( diff ) {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We disable the animation if the user has a preference for reduced\n\t\t// motion, if the user is typing (insertion by Enter), or if the block\n\t\t// count exceeds the threshold (insertion caused all the blocks that\n\t\t// follow to animate).\n\t\t// To do: consider enableing the _moving_ animation even for large\n\t\t// posts, while only disabling the _insertion_ animation?\n\t\tconst disableAnimation =\n\t\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||\n\t\t\tisTyping() ||\n\t\t\tgetGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;\n\n\t\tif ( disableAnimation ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPartOfSelection =\n\t\t\tisSelected ||\n\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\tisAncestorMultiSelected( clientId );\n\t\t// Make sure the other blocks move under the selected block(s).\n\t\tconst zIndex = isPartOfSelection ? '1' : '';\n\n\t\tconst controller = new Controller( {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\t\tonChange( { value } ) {\n\t\t\t\tif ( ! ref.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet { x, y } = value;\n\t\t\t\tx = Math.round( x );\n\t\t\t\ty = Math.round( y );\n\t\t\t\tconst finishedMoving = x === 0 && y === 0;\n\t\t\t\tref.current.style.transformOrigin = 'center center';\n\t\t\t\tref.current.style.transform = finishedMoving\n\t\t\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\t\t\tref.current.style.zIndex = zIndex;\n\t\t\t\tpreserveScrollPosition();\n\t\t\t},\n\t\t} );\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\tconst x = Math.round( previous.left - destination.left );\n\t\tconst y = Math.round( previous.top - destination.top );\n\n\t\tcontroller.start( { x: 0, y: 0, from: { x, y } } );\n\n\t\treturn () => {\n\t\t\tcontroller.stop();\n\t\t};\n\t}, [\n\t\tprevious,\n\t\tprevRect,\n\t\tclientId,\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t] );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACrE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,GAAG;AAErC,SAASC,mBAAmBA,CAAEC,OAAO,EAAG;EACvC,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAAEC,wBAAwB;EAAEC;AAAS,CAAC,EAAG;EACrE,MAAMC,GAAG,GAAGf,MAAM,CAAC,CAAC;EACpB,MAAM;IACLgB,QAAQ;IACRC,mBAAmB;IACnBC,eAAe;IACfC,yBAAyB;IACzBC,oBAAoB;IACpBC;EACD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K,CAAC;IACxD,MAAM+B,CAAC,GAAGO,IAAI,CAACC,KAAK,CAAE3B,QAAQ,CAACd,GAAG,GAAG+C,WAAW,CAAC/C,GAAI,CAAC;IAEtD+B,UAAU,CAACiB,KAAK,CAAE;MAAEhB,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEgB,IAAI,EAAE;QAAEjB,CAAC;QAAEC;MAAE;IAAE,CAAE,CAAC;IAElD,OAAO,MAAM;MACZF,UAAU,CAACmB,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["Controller","useLayoutEffect","useMemo","useRef","getScrollContainer","useSelect","store","blockEditorStore","BLOCK_ANIMATION_THRESHOLD","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","triggerAnimationOnChange","clientId","ref","isTyping","getGlobalBlockCount","isBlockSelected","isFirstMultiSelectedBlock","isBlockMultiSelected","isAncestorMultiSelected","previous","prevRect","current","getBoundingClientRect","scrollContainer","isSelected","adjustScrolling","preserveScrollPosition","blockRect","diff","scrollTop","disableAnimation","window","matchMedia","matches","isPartOfSelection","zIndex","controller","x","y","config","mass","tension","friction","onChange","value","Math","round","finishedMoving","style","transformOrigin","transform","undefined","destination","start","from","stop","set"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Controller } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useRef } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\nfunction getAbsolutePosition( element ) {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n}\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n * @param {string} $1.clientId\n */\nfunction useMovingAnimation( { triggerAnimationOnChange, clientId } ) {\n\tconst ref = useRef();\n\tconst {\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t} = useSelect( blockEditorStore );\n\n\t// Whenever the trigger changes, we need to take a snapshot of the current\n\t// position of the block to use it as a destination point for the animation.\n\tconst { previous, prevRect } = useMemo(\n\t\t() => ( {\n\t\t\tprevious: ref.current && getAbsolutePosition( ref.current ),\n\t\t\tprevRect: ref.current && ref.current.getBoundingClientRect(),\n\t\t} ),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous || ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\t\tconst isSelected = isBlockSelected( clientId );\n\t\tconst adjustScrolling =\n\t\t\tisSelected || isFirstMultiSelectedBlock( clientId );\n\n\t\tfunction preserveScrollPosition() {\n\t\t\tif ( adjustScrolling && prevRect ) {\n\t\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\t\tif ( diff ) {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We disable the animation if the user has a preference for reduced\n\t\t// motion, if the user is typing (insertion by Enter), or if the block\n\t\t// count exceeds the threshold (insertion caused all the blocks that\n\t\t// follow to animate).\n\t\t// To do: consider enableing the _moving_ animation even for large\n\t\t// posts, while only disabling the _insertion_ animation?\n\t\tconst disableAnimation =\n\t\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||\n\t\t\tisTyping() ||\n\t\t\tgetGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;\n\n\t\tif ( disableAnimation ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPartOfSelection =\n\t\t\tisSelected ||\n\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\tisAncestorMultiSelected( clientId );\n\t\t// Make sure the other blocks move under the selected block(s).\n\t\tconst zIndex = isPartOfSelection ? '1' : '';\n\n\t\tconst controller = new Controller( {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\t\tonChange( { value } ) {\n\t\t\t\tif ( ! ref.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet { x, y } = value;\n\t\t\t\tx = Math.round( x );\n\t\t\t\ty = Math.round( y );\n\t\t\t\tconst finishedMoving = x === 0 && y === 0;\n\t\t\t\tref.current.style.transformOrigin = 'center center';\n\t\t\t\tref.current.style.transform = finishedMoving\n\t\t\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\t\t\tref.current.style.zIndex = zIndex;\n\t\t\t\tpreserveScrollPosition();\n\t\t\t},\n\t\t} );\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\tconst x = Math.round( previous.left - destination.left );\n\t\tconst y = Math.round( previous.top - destination.top );\n\n\t\tcontroller.start( { x: 0, y: 0, from: { x, y } } );\n\n\t\treturn () => {\n\t\t\tcontroller.stop();\n\t\t\tcontroller.set( { x: 0, y: 0 } );\n\t\t};\n\t}, [\n\t\tprevious,\n\t\tprevRect,\n\t\tclientId,\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t] );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACrE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,GAAG;AAErC,SAASC,mBAAmBA,CAAEC,OAAO,EAAG;EACvC,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAAEC,wBAAwB;EAAEC;AAAS,CAAC,EAAG;EACrE,MAAMC,GAAG,GAAGf,MAAM,CAAC,CAAC;EACpB,MAAM;IACLgB,QAAQ;IACRC,mBAAmB;IACnBC,eAAe;IACfC,yBAAyB;IACzBC,oBAAoB;IACpBC;EACD,CAAC,GAAGnB,SAAS,CAAEE,gBAAiB,CAAC;;EAEjC;EACA;EACA,MAAM;IAAEkB,QAAQ;IAAEC;EAAS,CAAC,GAAGxB,OAAO,CACrC,OAAQ;IACPuB,QAAQ,EAAEP,GAAG,CAACS,OAAO,IAAIlB,mBAAmB,CAAES,GAAG,CAACS,OAAQ,CAAC;IAC3DD,QAAQ,EAAER,GAAG,CAACS,OAAO,IAAIT,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AAC;IAElD,OAAO,MAAM;MACZF,UAAU,CAACmB,IAAI,CAAC,CAAC;MACjBnB,UAAU,CAACoB,GAAG,CAAE;QAAEnB,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE;MAAE,CAAE,CAAC;IACjC,CAAC;EACF,CAAC,EAAE,CACFnB,QAAQ,EACRC,QAAQ,EACRT,QAAQ,EACRE,QAAQ,EACRC,mBAAmB,EACnBC,eAAe,EACfC,yBAAyB,EACzBC,oBAAoB,EACpBC,uBAAuB,CACtB,CAAC;EAEH,OAAON,GAAG;AACX;AAEA,eAAeH,kBAAkB"}
|
|
@@ -16,20 +16,25 @@ import { normalizeIconObject } from '@wordpress/blocks';
|
|
|
16
16
|
*/
|
|
17
17
|
import styles from './style.scss';
|
|
18
18
|
function Warning({
|
|
19
|
+
actions,
|
|
19
20
|
title,
|
|
20
21
|
message,
|
|
21
22
|
icon,
|
|
22
23
|
iconClass,
|
|
23
24
|
preferredColorScheme,
|
|
24
25
|
getStylesFromColorScheme,
|
|
26
|
+
containerStyle: extraContainerStyle,
|
|
27
|
+
titleStyle: extraTitleStyle,
|
|
28
|
+
messageStyle: extraMessageStyle,
|
|
25
29
|
...viewProps
|
|
26
30
|
}) {
|
|
27
31
|
icon = icon && normalizeIconObject(icon);
|
|
28
32
|
const internalIconClass = 'warning-icon' + '-' + preferredColorScheme;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
33
|
+
const containerStyle = [getStylesFromColorScheme(styles.container, styles.containerDark), extraContainerStyle];
|
|
34
|
+
const titleStyle = [getStylesFromColorScheme(styles.title, styles.titleDark), extraTitleStyle];
|
|
35
|
+
const messageStyle = [getStylesFromColorScheme(styles.message, styles.messageDark), extraMessageStyle];
|
|
31
36
|
return createElement(View, {
|
|
32
|
-
style:
|
|
37
|
+
style: containerStyle,
|
|
33
38
|
...viewProps
|
|
34
39
|
}, icon && createElement(View, {
|
|
35
40
|
style: styles.icon
|
|
@@ -40,7 +45,7 @@ function Warning({
|
|
|
40
45
|
style: titleStyle
|
|
41
46
|
}, title), message && createElement(Text, {
|
|
42
47
|
style: messageStyle
|
|
43
|
-
}, message));
|
|
48
|
+
}, message), actions);
|
|
44
49
|
}
|
|
45
50
|
export default withPreferredColorScheme(Warning);
|
|
46
51
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Text","Icon","withPreferredColorScheme","normalizeIconObject","styles","Warning","title","message","icon","iconClass","preferredColorScheme","getStylesFromColorScheme","
|
|
1
|
+
{"version":3,"names":["View","Text","Icon","withPreferredColorScheme","normalizeIconObject","styles","Warning","actions","title","message","icon","iconClass","preferredColorScheme","getStylesFromColorScheme","containerStyle","extraContainerStyle","titleStyle","extraTitleStyle","messageStyle","extraMessageStyle","viewProps","internalIconClass","container","containerDark","titleDark","messageDark","createElement","style","className","src"],"sources":["@wordpress/block-editor/src/components/warning/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { normalizeIconObject } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nfunction Warning( {\n\tactions,\n\ttitle,\n\tmessage,\n\ticon,\n\ticonClass,\n\tpreferredColorScheme,\n\tgetStylesFromColorScheme,\n\tcontainerStyle: extraContainerStyle,\n\ttitleStyle: extraTitleStyle,\n\tmessageStyle: extraMessageStyle,\n\t...viewProps\n} ) {\n\ticon = icon && normalizeIconObject( icon );\n\tconst internalIconClass = 'warning-icon' + '-' + preferredColorScheme;\n\n\tconst containerStyle = [\n\t\tgetStylesFromColorScheme( styles.container, styles.containerDark ),\n\t\textraContainerStyle,\n\t];\n\tconst titleStyle = [\n\t\tgetStylesFromColorScheme( styles.title, styles.titleDark ),\n\t\textraTitleStyle,\n\t];\n\tconst messageStyle = [\n\t\tgetStylesFromColorScheme( styles.message, styles.messageDark ),\n\t\textraMessageStyle,\n\t];\n\n\treturn (\n\t\t<View style={ containerStyle } { ...viewProps }>\n\t\t\t{ icon && (\n\t\t\t\t<View style={ styles.icon }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={ iconClass || internalIconClass }\n\t\t\t\t\t\ticon={ icon && icon.src ? icon.src : icon }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t{ title && <Text style={ titleStyle }>{ title }</Text> }\n\t\t\t{ message && <Text style={ messageStyle }>{ message }</Text> }\n\t\t\t{ actions }\n\t\t</View>\n\t);\n}\n\nexport default withPreferredColorScheme( Warning );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,IAAI,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AAEjC,SAASC,OAAOA,CAAE;EACjBC,OAAO;EACPC,KAAK;EACLC,OAAO;EACPC,IAAI;EACJC,SAAS;EACTC,oBAAoB;EACpBC,wBAAwB;EACxBC,cAAc,EAAEC,mBAAmB;EACnCC,UAAU,EAAEC,eAAe;EAC3BC,YAAY,EAAEC,iBAAiB;EAC/B,GAAGC;AACJ,CAAC,EAAG;EACHV,IAAI,GAAGA,IAAI,IAAIN,mBAAmB,CAAEM,IAAK,CAAC;EAC1C,MAAMW,iBAAiB,GAAG,cAAc,GAAG,GAAG,GAAGT,oBAAoB;EAErE,MAAME,cAAc,GAAG,CACtBD,wBAAwB,CAAER,MAAM,CAACiB,SAAS,EAAEjB,MAAM,CAACkB,aAAc,CAAC,EAClER,mBAAmB,CACnB;EACD,MAAMC,UAAU,GAAG,CAClBH,wBAAwB,CAAER,MAAM,CAACG,KAAK,EAAEH,MAAM,CAACmB,SAAU,CAAC,EAC1DP,eAAe,CACf;EACD,MAAMC,YAAY,GAAG,CACpBL,wBAAwB,CAAER,MAAM,CAACI,OAAO,EAAEJ,MAAM,CAACoB,WAAY,CAAC,EAC9DN,iBAAiB,CACjB;EAED,OACCO,aAAA,CAAC1B,IAAI;IAAC2B,KAAK,EAAGb,cAAgB;IAAA,GAAMM;EAAS,GAC1CV,IAAI,IACLgB,aAAA,CAAC1B,IAAI;IAAC2B,KAAK,EAAGtB,MAAM,CAACK;EAAM,GAC1BgB,aAAA,CAACxB,IAAI;IACJ0B,SAAS,EAAGjB,SAAS,IAAIU,iBAAmB;IAC5CX,IAAI,EAAGA,IAAI,IAAIA,IAAI,CAACmB,GAAG,GAAGnB,IAAI,CAACmB,GAAG,GAAGnB;EAAM,CAC3C,CACI,CACN,EACCF,KAAK,IAAIkB,aAAA,CAACzB,IAAI;IAAC0B,KAAK,EAAGX;EAAY,GAAGR,KAAa,CAAC,EACpDC,OAAO,IAAIiB,aAAA,CAACzB,IAAI;IAAC0B,KAAK,EAAGT;EAAc,GAAGT,OAAe,CAAC,EAC1DF,OACG,CAAC;AAET;AAEA,eAAeJ,wBAAwB,CAAEG,OAAQ,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { addFilter } from '@wordpress/hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { TextControl, ExternalLink } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
9
|
import { Platform } from '@wordpress/element';
|
|
@@ -51,13 +51,17 @@ export function addAttribute(settings) {
|
|
|
51
51
|
return settings;
|
|
52
52
|
}
|
|
53
53
|
function BlockEditAnchorControlPure({
|
|
54
|
-
name: blockName,
|
|
55
54
|
anchor,
|
|
56
55
|
setAttributes
|
|
57
56
|
}) {
|
|
58
57
|
const blockEditingMode = useBlockEditingMode();
|
|
58
|
+
if (blockEditingMode !== 'default') {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
59
61
|
const isWeb = Platform.OS === 'web';
|
|
60
|
-
|
|
62
|
+
return createElement(InspectorControls, {
|
|
63
|
+
group: "advanced"
|
|
64
|
+
}, createElement(TextControl, {
|
|
61
65
|
__nextHasNoMarginBottom: true,
|
|
62
66
|
__next40pxDefaultSize: true,
|
|
63
67
|
className: "html-anchor-control",
|
|
@@ -75,12 +79,7 @@ function BlockEditAnchorControlPure({
|
|
|
75
79
|
},
|
|
76
80
|
autoCapitalize: "none",
|
|
77
81
|
autoComplete: "off"
|
|
78
|
-
});
|
|
79
|
-
return createElement(Fragment, null, isWeb && blockEditingMode === 'default' && createElement(InspectorControls, {
|
|
80
|
-
group: "advanced"
|
|
81
|
-
}, textControl), !isWeb && blockName === 'core/heading' && createElement(InspectorControls, null, createElement(PanelBody, {
|
|
82
|
-
title: __('Heading settings')
|
|
83
|
-
}, textControl)));
|
|
82
|
+
}));
|
|
84
83
|
}
|
|
85
84
|
export default {
|
|
86
85
|
addSaveProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","
|
|
1
|
+
{"version":3,"names":["addFilter","TextControl","ExternalLink","__","hasBlockSupport","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","BlockEditAnchorControlPure","setAttributes","blockEditingMode","isWeb","OS","createElement","group","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","addSaveProps","edit","attributeKeys","hasSupport","name","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst isWeb = Platform.OS === 'web';\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tvalue={ anchor || '' }\n\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,EAAEC,YAAY,QAAQ,uBAAuB;AACjE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,QAAQ,QAAQ,oBAAoB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CAAC,EAECmB,KAAK,IACNE,aAAA,CAACtB,YAAY;MACZ8B,IAAI,EAAG7B,EAAE,CACR,yDACD;IAAG,GAEDA,EAAE,CAAE,0BAA2B,CACpB,CAEd,CACF;IACD8B,KAAK,EAAGf,MAAM,IAAI,EAAI;IACtBgB,WAAW,EAAG,CAAEZ,KAAK,GAAGnB,EAAE,CAAE,eAAgB,CAAC,GAAG,IAAM;IACtDgC,QAAQ,EAAKC,SAAS,IAAM;MAC3BA,SAAS,GAAGA,SAAS,CAACC,OAAO,CAAE7B,YAAY,EAAE,GAAI,CAAC;MAClDY,aAAa,CAAE;QACdF,MAAM,EAAEkB;MACT,CAAE,CAAC;IACJ,CAAG;IACHE,cAAc,EAAC,MAAM;IACrBC,YAAY,EAAC;EAAK,CAClB,CACiB,CAAC;AAEtB;AAEA,eAAe;EACdC,YAAY;EACZC,IAAI,EAAEtB,0BAA0B;EAChCuB,aAAa,EAAE,CAAE,QAAQ,CAAE;EAC3BC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOxC,eAAe,CAAEwC,IAAI,EAAE,QAAS,CAAC;EACzC;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASJ,YAAYA,CAAEK,UAAU,EAAEC,SAAS,EAAE7B,UAAU,EAAG;EACjE,IAAKb,eAAe,CAAE0C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAG9B,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO2B,UAAU;AAClB;AAEA7C,SAAS,CAAE,0BAA0B,EAAE,uBAAuB,EAAEc,YAAa,CAAC"}
|
|
@@ -73,6 +73,38 @@ export function hasBackgroundSupport(blockName, feature = 'any') {
|
|
|
73
73
|
}
|
|
74
74
|
return !!support?.[feature];
|
|
75
75
|
}
|
|
76
|
+
function useBlockProps({
|
|
77
|
+
name,
|
|
78
|
+
style
|
|
79
|
+
}) {
|
|
80
|
+
if (!hasBackgroundSupport(name) || !style?.background?.backgroundImage) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const backgroundImage = style?.background?.backgroundImage;
|
|
84
|
+
let props;
|
|
85
|
+
|
|
86
|
+
// Set block background defaults.
|
|
87
|
+
if (backgroundImage?.source === 'file' && !!backgroundImage?.url) {
|
|
88
|
+
if (!style?.background?.backgroundSize) {
|
|
89
|
+
props = {
|
|
90
|
+
style: {
|
|
91
|
+
backgroundSize: 'cover'
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if ('contain' === style?.background?.backgroundSize && !style?.background?.backgroundPosition) {
|
|
96
|
+
props = {
|
|
97
|
+
style: {
|
|
98
|
+
backgroundPosition: 'center'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!props) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
return props;
|
|
107
|
+
}
|
|
76
108
|
|
|
77
109
|
/**
|
|
78
110
|
* Resets the background image block support attributes. This can be used when disabling
|
|
@@ -339,7 +371,7 @@ function BackgroundSizePanelItem({
|
|
|
339
371
|
// If the current value is `cover` and the repeat value is `undefined`, then
|
|
340
372
|
// the toggle should be unchecked as the default state. Otherwise, the toggle
|
|
341
373
|
// should reflect the current repeat value.
|
|
342
|
-
const repeatCheckedValue = repeatValue === 'no-repeat' || currentValueForToggle === 'cover' && repeatValue === undefined
|
|
374
|
+
const repeatCheckedValue = !(repeatValue === 'no-repeat' || currentValueForToggle === 'cover' && repeatValue === undefined);
|
|
343
375
|
const hasValue = hasBackgroundSizeValue(style);
|
|
344
376
|
const resetAllFilter = useCallback(previousValue => {
|
|
345
377
|
return {
|
|
@@ -458,4 +490,9 @@ export function BackgroundImagePanel(props) {
|
|
|
458
490
|
...props
|
|
459
491
|
}));
|
|
460
492
|
}
|
|
493
|
+
export default {
|
|
494
|
+
useBlockProps,
|
|
495
|
+
attributeKeys: ['style'],
|
|
496
|
+
hasSupport: hasBackgroundSupport
|
|
497
|
+
};
|
|
461
498
|
//# sourceMappingURL=background.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","focus","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUnitControl","UnitControl","__experimentalVStack","VStack","DropZone","FlexItem","FocalPointPicker","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","useRef","__","sprintf","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","useSettings","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","style","hasValue","background","backgroundImage","id","url","hasBackgroundSizeValue","backgroundPosition","undefined","backgroundSize","hasBackgroundSupport","blockName","feature","OS","support","backgroundRepeat","resetBackgroundImage","setAttributes","resetBackgroundSize","getBackgroundImageClasses","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","isShownByDefault","mediaUpload","select","getBlockAttributes","getSettings","title","replaceContainerRef","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","panelId","ref","mediaId","mediaURL","accept","onSelect","name","variant","onClick","toggleButton","tabbable","find","current","click","backgroundSizeHelpText","value","coordsToBackgroundPosition","isNaN","x","y","backgroundPositionToCoords","split","map","v","parseFloat","BackgroundSizePanelItem","sizeValue","repeatValue","currentValueForToggle","repeatCheckedValue","updateBackgroundSize","next","nextRepeat","updateBackgroundPosition","toggleIsRepeated","spacing","__next40pxDefaultSize","onChange","size","isBlock","help","key","checked","BackgroundImagePanel","props","showBackgroundSize","defaultControls","group"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalVStack as VStack,\n\tDropZone,\n\tFlexItem,\n\tFocalPointPicker,\n\tMenuItem,\n\tVisuallyHidden,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport { useSettings } from '../components/use-settings';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( style ) {\n\tconst hasValue =\n\t\t!! style?.background?.backgroundImage?.id ||\n\t\t!! style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Checks if there is a current value in the background size block support\n * attributes. Background size values include background size as well\n * as background position.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether or not the block has a background size value set.\n */\nexport function hasBackgroundSizeValue( style ) {\n\treturn (\n\t\tstyle?.background?.backgroundPosition !== undefined ||\n\t\tstyle?.background?.backgroundSize !== undefined\n\t);\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} style Style attribute.\n * @param {Function} setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( style = {}, setAttributes ) {\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Resets the background size block support attributes. This can be used when disabling\n * the background size controls for a block via a `ToolsPanel`.\n *\n * @param {Object} style Style attribute.\n * @param {Function} setAttributes Function to set block's attributes.\n */\nfunction resetBackgroundSize( style = {}, setAttributes ) {\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundPosition: undefined,\n\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\tbackgroundSize: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\n}\n\nfunction InspectorImagePreview( { label, filename, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-hooks__background__inspector-image-indicator-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-image': imgUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\taria-hidden\n\t\t\t\t>\n\t\t\t\t\t{ imgUrl && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-image-indicator\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackgroundImage: `url(${ imgUrl })`,\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</span>\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ filename\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t\t\t\t\t__( 'Selected image: %s' ),\n\t\t\t\t\t\t\t\t\tfilename\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'No image selected' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst { style, mediaUpload } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\tmediaUpload: getSettings().mediaUpload,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { id, title, url } = style?.background?.backgroundImage || {};\n\n\tconst replaceContainerRef = useRef();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst hasValue = hasBackgroundImageValue( style );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( style, setAttributes ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-container\"\n\t\t\t\tref={ replaceContainerRef }\n\t\t\t>\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tname={\n\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t\t\t\t\tfilename={ title }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t>\n\t\t\t\t\t{ hasValue && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst [ toggleButton ] = focus.tabbable.find(\n\t\t\t\t\t\t\t\t\treplaceContainerRef.current\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t// Focus the toggle button and close the dropdown menu.\n\t\t\t\t\t\t\t\t// This ensures similar behaviour as to selecting an image, where the dropdown is\n\t\t\t\t\t\t\t\t// closed and focus is redirected to the dropdown toggle button.\n\t\t\t\t\t\t\t\ttoggleButton?.focus();\n\t\t\t\t\t\t\t\ttoggleButton?.click();\n\t\t\t\t\t\t\t\tresetBackgroundImage( style, setAttributes );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tlabel={ __( 'Drop to upload' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nfunction backgroundSizeHelpText( value ) {\n\tif ( value === 'cover' || value === undefined ) {\n\t\treturn __( 'Image covers the space evenly.' );\n\t}\n\tif ( value === 'contain' ) {\n\t\treturn __( 'Image is contained without distortion.' );\n\t}\n\treturn __( 'Specify a fixed width.' );\n}\n\nexport const coordsToBackgroundPosition = ( value ) => {\n\tif ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {\n\t\treturn undefined;\n\t}\n\n\tconst x = isNaN( value.x ) ? 0.5 : value.x;\n\tconst y = isNaN( value.y ) ? 0.5 : value.y;\n\n\treturn `${ x * 100 }% ${ y * 100 }%`;\n};\n\nexport const backgroundPositionToCoords = ( value ) => {\n\tif ( ! value ) {\n\t\treturn { x: undefined, y: undefined };\n\t}\n\n\tlet [ x, y ] = value.split( ' ' ).map( ( v ) => parseFloat( v ) / 100 );\n\tx = isNaN( x ) ? undefined : x;\n\ty = isNaN( y ) ? x : y;\n\n\treturn { x, y };\n};\n\nfunction BackgroundSizePanelItem( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\n\tconst sizeValue = style?.background?.backgroundSize;\n\tconst repeatValue = style?.background?.backgroundRepeat;\n\n\t// An `undefined` value is treated as `cover` by the toggle group control.\n\t// An empty string is treated as `auto` by the toggle group control. This\n\t// allows a user to select \"Size\" and then enter a custom value, with an\n\t// empty value being treated as `auto`.\n\tconst currentValueForToggle =\n\t\t( sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ) ||\n\t\tsizeValue === ''\n\t\t\t? 'auto'\n\t\t\t: sizeValue || 'cover';\n\n\t// If the current value is `cover` and the repeat value is `undefined`, then\n\t// the toggle should be unchecked as the default state. Otherwise, the toggle\n\t// should reflect the current repeat value.\n\tconst repeatCheckedValue =\n\t\trepeatValue === 'no-repeat' ||\n\t\t( currentValueForToggle === 'cover' && repeatValue === undefined )\n\t\t\t? false\n\t\t\t: true;\n\n\tconst hasValue = hasBackgroundSizeValue( style );\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...previousValue.style?.background,\n\t\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\t\tbackgroundSize: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst updateBackgroundSize = ( next ) => {\n\t\t// When switching to 'contain' toggle the repeat off.\n\t\tlet nextRepeat = repeatValue;\n\n\t\tif ( next === 'contain' ) {\n\t\t\tnextRepeat = 'no-repeat';\n\t\t}\n\n\t\tif (\n\t\t\t( currentValueForToggle === 'cover' ||\n\t\t\t\tcurrentValueForToggle === 'contain' ) &&\n\t\t\tnext === 'auto'\n\t\t) {\n\t\t\tnextRepeat = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat: nextRepeat,\n\t\t\t\t\tbackgroundSize: next,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst updateBackgroundPosition = ( next ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundPosition: coordsToBackgroundPosition( next ),\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst toggleIsRepeated = () => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat:\n\t\t\t\t\t\trepeatCheckedValue === true ? 'no-repeat' : undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\treturn (\n\t\t<VStack\n\t\t\tas={ ToolsPanelItem }\n\t\t\tspacing={ 2 }\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Size' ) }\n\t\t\tonDeselect={ () => resetBackgroundSize( style, setAttributes ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<FocalPointPicker\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\turl={ style?.background?.backgroundImage?.url }\n\t\t\t\tvalue={ backgroundPositionToCoords(\n\t\t\t\t\tstyle?.background?.backgroundPosition\n\t\t\t\t) }\n\t\t\t\tonChange={ updateBackgroundPosition }\n\t\t\t/>\n\t\t\t<ToggleGroupControl\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\tvalue={ currentValueForToggle }\n\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\tisBlock\n\t\t\t\thelp={ backgroundSizeHelpText( sizeValue ) }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'cover' }\n\t\t\t\t\tvalue={ 'cover' }\n\t\t\t\t\tlabel={ __( 'Cover' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'contain' }\n\t\t\t\t\tvalue={ 'contain' }\n\t\t\t\t\tlabel={ __( 'Contain' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'auto' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ? (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\t\tvalue={ sizeValue }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t\t{ currentValueForToggle !== 'cover' && (\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Repeat' ) }\n\t\t\t\t\tchecked={ repeatCheckedValue }\n\t\t\t\t\tonChange={ toggleIsRepeated }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst [ backgroundImage, backgroundSize ] = useSettings(\n\t\t'background.backgroundImage',\n\t\t'background.backgroundSize'\n\t);\n\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst showBackgroundSize = !! (\n\t\tbackgroundSize && hasBackgroundSupport( props.name, 'backgroundSize' )\n\t);\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem\n\t\t\t\tisShownByDefault={ defaultControls?.backgroundImage }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t\t{ showBackgroundSize && (\n\t\t\t\t<BackgroundSizePanelItem\n\t\t\t\t\tisShownByDefault={ defaultControls?.backgroundSize }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,aAAa,EACbC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EAChBC,QAAQ,EACRC,cAAc,EACdC,uBAAuB,IAAIC,SAAS,EACpCC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iB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kBAAkB,GAAG,CAAC,EAC3B9F,cAAc,IAAIC,oBAAoB,CAAE4F,KAAK,CAACtC,IAAI,EAAE,gBAAiB,CAAC,CACtE;EAED,MAAMwC,eAAe,GAAGlJ,eAAe,CAAEgJ,KAAK,CAACtC,IAAI,EAAE,CACpDnE,sBAAsB,EACtB,+BAA+B,CAC9B,CAAC;EAEH,OACC4B,aAAA,CAACjC,iBAAiB;IAACiH,KAAK,EAAC;EAAY,GACpChF,aAAA,CAACK,wBAAwB;IACxBE,gBAAgB,EAAGwE,eAAe,EAAErG,eAAiB;IAAA,GAChDmG;EAAK,CACV,CAAC,EACAC,kBAAkB,IACnB9E,aAAA,CAAC0D,uBAAuB;IACvBnD,gBAAgB,EAAGwE,eAAe,EAAE/F,cAAgB;IAAA,GAC/C6F;EAAK,CACV,CAEgB,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","focus","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUnitControl","UnitControl","__experimentalVStack","VStack","DropZone","FlexItem","FocalPointPicker","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","useRef","__","sprintf","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","useSettings","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","style","hasValue","background","backgroundImage","id","url","hasBackgroundSizeValue","backgroundPosition","undefined","backgroundSize","hasBackgroundSupport","blockName","feature","OS","support","backgroundRepeat","useBlockProps","name","props","source","resetBackgroundImage","setAttributes","resetBackgroundSize","getBackgroundImageClasses","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","isShownByDefault","mediaUpload","select","getBlockAttributes","getSettings","title","replaceContainerRef","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","panelId","ref","mediaId","mediaURL","accept","onSelect","variant","onClick","toggleButton","tabbable","find","current","click","backgroundSizeHelpText","value","coordsToBackgroundPosition","isNaN","x","y","backgroundPositionToCoords","split","map","v","parseFloat","BackgroundSizePanelItem","sizeValue","repeatValue","currentValueForToggle","repeatCheckedValue","updateBackgroundSize","next","nextRepeat","updateBackgroundPosition","toggleIsRepeated","spacing","__next40pxDefaultSize","onChange","size","isBlock","help","key","checked","BackgroundImagePanel","showBackgroundSize","defaultControls","group","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalVStack as VStack,\n\tDropZone,\n\tFlexItem,\n\tFocalPointPicker,\n\tMenuItem,\n\tVisuallyHidden,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport { useSettings } from '../components/use-settings';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( style ) {\n\tconst hasValue =\n\t\t!! style?.background?.backgroundImage?.id ||\n\t\t!! style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Checks if there is a current value in the background size block support\n * attributes. Background size values include background size as well\n * as background position.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether or not the block has a background size value set.\n */\nexport function hasBackgroundSizeValue( style ) {\n\treturn (\n\t\tstyle?.background?.backgroundPosition !== undefined ||\n\t\tstyle?.background?.backgroundSize !== undefined\n\t);\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundImage = style?.background?.backgroundImage;\n\tlet props;\n\n\t// Set block background defaults.\n\tif ( backgroundImage?.source === 'file' && !! backgroundImage?.url ) {\n\t\tif ( ! style?.background?.backgroundSize ) {\n\t\t\tprops = {\n\t\t\t\tstyle: {\n\t\t\t\t\tbackgroundSize: 'cover',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\t'contain' === style?.background?.backgroundSize &&\n\t\t\t! style?.background?.backgroundPosition\n\t\t) {\n\t\t\tprops = {\n\t\t\t\tstyle: {\n\t\t\t\t\tbackgroundPosition: 'center',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\tif ( ! props ) {\n\t\treturn;\n\t}\n\n\treturn props;\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} style Style attribute.\n * @param {Function} setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( style = {}, setAttributes ) {\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Resets the background size block support attributes. This can be used when disabling\n * the background size controls for a block via a `ToolsPanel`.\n *\n * @param {Object} style Style attribute.\n * @param {Function} setAttributes Function to set block's attributes.\n */\nfunction resetBackgroundSize( style = {}, setAttributes ) {\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundPosition: undefined,\n\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\tbackgroundSize: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\n}\n\nfunction InspectorImagePreview( { label, filename, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-hooks__background__inspector-image-indicator-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-image': imgUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\taria-hidden\n\t\t\t\t>\n\t\t\t\t\t{ imgUrl && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-image-indicator\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackgroundImage: `url(${ imgUrl })`,\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</span>\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ filename\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t\t\t\t\t__( 'Selected image: %s' ),\n\t\t\t\t\t\t\t\t\tfilename\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'No image selected' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst { style, mediaUpload } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\tmediaUpload: getSettings().mediaUpload,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { id, title, url } = style?.background?.backgroundImage || {};\n\n\tconst replaceContainerRef = useRef();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst hasValue = hasBackgroundImageValue( style );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( style, setAttributes ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-container\"\n\t\t\t\tref={ replaceContainerRef }\n\t\t\t>\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tname={\n\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t\t\t\t\tfilename={ title }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t>\n\t\t\t\t\t{ hasValue && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst [ toggleButton ] = focus.tabbable.find(\n\t\t\t\t\t\t\t\t\treplaceContainerRef.current\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t// Focus the toggle button and close the dropdown menu.\n\t\t\t\t\t\t\t\t// This ensures similar behaviour as to selecting an image, where the dropdown is\n\t\t\t\t\t\t\t\t// closed and focus is redirected to the dropdown toggle button.\n\t\t\t\t\t\t\t\ttoggleButton?.focus();\n\t\t\t\t\t\t\t\ttoggleButton?.click();\n\t\t\t\t\t\t\t\tresetBackgroundImage( style, setAttributes );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tlabel={ __( 'Drop to upload' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nfunction backgroundSizeHelpText( value ) {\n\tif ( value === 'cover' || value === undefined ) {\n\t\treturn __( 'Image covers the space evenly.' );\n\t}\n\tif ( value === 'contain' ) {\n\t\treturn __( 'Image is contained without distortion.' );\n\t}\n\treturn __( 'Specify a fixed width.' );\n}\n\nexport const coordsToBackgroundPosition = ( value ) => {\n\tif ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {\n\t\treturn undefined;\n\t}\n\n\tconst x = isNaN( value.x ) ? 0.5 : value.x;\n\tconst y = isNaN( value.y ) ? 0.5 : value.y;\n\n\treturn `${ x * 100 }% ${ y * 100 }%`;\n};\n\nexport const backgroundPositionToCoords = ( value ) => {\n\tif ( ! value ) {\n\t\treturn { x: undefined, y: undefined };\n\t}\n\n\tlet [ x, y ] = value.split( ' ' ).map( ( v ) => parseFloat( v ) / 100 );\n\tx = isNaN( x ) ? undefined : x;\n\ty = isNaN( y ) ? x : y;\n\n\treturn { x, y };\n};\n\nfunction BackgroundSizePanelItem( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\n\tconst sizeValue = style?.background?.backgroundSize;\n\tconst repeatValue = style?.background?.backgroundRepeat;\n\n\t// An `undefined` value is treated as `cover` by the toggle group control.\n\t// An empty string is treated as `auto` by the toggle group control. This\n\t// allows a user to select \"Size\" and then enter a custom value, with an\n\t// empty value being treated as `auto`.\n\tconst currentValueForToggle =\n\t\t( sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ) ||\n\t\tsizeValue === ''\n\t\t\t? 'auto'\n\t\t\t: sizeValue || 'cover';\n\n\t// If the current value is `cover` and the repeat value is `undefined`, then\n\t// the toggle should be unchecked as the default state. Otherwise, the toggle\n\t// should reflect the current repeat value.\n\tconst repeatCheckedValue = ! (\n\t\trepeatValue === 'no-repeat' ||\n\t\t( currentValueForToggle === 'cover' && repeatValue === undefined )\n\t);\n\n\tconst hasValue = hasBackgroundSizeValue( style );\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...previousValue.style?.background,\n\t\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\t\tbackgroundSize: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst updateBackgroundSize = ( next ) => {\n\t\t// When switching to 'contain' toggle the repeat off.\n\t\tlet nextRepeat = repeatValue;\n\n\t\tif ( next === 'contain' ) {\n\t\t\tnextRepeat = 'no-repeat';\n\t\t}\n\n\t\tif (\n\t\t\t( currentValueForToggle === 'cover' ||\n\t\t\t\tcurrentValueForToggle === 'contain' ) &&\n\t\t\tnext === 'auto'\n\t\t) {\n\t\t\tnextRepeat = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat: nextRepeat,\n\t\t\t\t\tbackgroundSize: next,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst updateBackgroundPosition = ( next ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundPosition: coordsToBackgroundPosition( next ),\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst toggleIsRepeated = () => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat:\n\t\t\t\t\t\trepeatCheckedValue === true ? 'no-repeat' : undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\treturn (\n\t\t<VStack\n\t\t\tas={ ToolsPanelItem }\n\t\t\tspacing={ 2 }\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Size' ) }\n\t\t\tonDeselect={ () => resetBackgroundSize( style, setAttributes ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<FocalPointPicker\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\turl={ style?.background?.backgroundImage?.url }\n\t\t\t\tvalue={ backgroundPositionToCoords(\n\t\t\t\t\tstyle?.background?.backgroundPosition\n\t\t\t\t) }\n\t\t\t\tonChange={ updateBackgroundPosition }\n\t\t\t/>\n\t\t\t<ToggleGroupControl\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\tvalue={ currentValueForToggle }\n\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\tisBlock\n\t\t\t\thelp={ backgroundSizeHelpText( sizeValue ) }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'cover' }\n\t\t\t\t\tvalue={ 'cover' }\n\t\t\t\t\tlabel={ __( 'Cover' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'contain' }\n\t\t\t\t\tvalue={ 'contain' }\n\t\t\t\t\tlabel={ __( 'Contain' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'auto' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ? (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\t\tvalue={ sizeValue }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t\t{ currentValueForToggle !== 'cover' && (\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Repeat' ) }\n\t\t\t\t\tchecked={ repeatCheckedValue }\n\t\t\t\t\tonChange={ toggleIsRepeated }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst [ backgroundImage, backgroundSize ] = useSettings(\n\t\t'background.backgroundImage',\n\t\t'background.backgroundSize'\n\t);\n\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst showBackgroundSize = !! (\n\t\tbackgroundSize && hasBackgroundSupport( props.name, 'backgroundSize' )\n\t);\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem\n\t\t\t\tisShownByDefault={ defaultControls?.backgroundImage }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t\t{ showBackgroundSize && (\n\t\t\t\t<BackgroundSizePanelItem\n\t\t\t\t\tisShownByDefault={ defaultControls?.backgroundSize }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,aAAa,EACbC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EAChBC,QAAQ,EACRC,cAAc,EACdC,uBAAuB,IAAIC,SAAS,EACpCC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AAClE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,QAAQ,gBAAgB;;A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utils';
|
|
5
5
|
import './compat';
|
|
6
6
|
import align from './align';
|
|
7
|
+
import background from './background';
|
|
7
8
|
import './lock';
|
|
8
9
|
import anchor from './anchor';
|
|
9
10
|
import ariaLabel from './aria-label';
|
|
@@ -26,7 +27,7 @@ import blockHooks from './block-hooks';
|
|
|
26
27
|
import blockRenaming from './block-renaming';
|
|
27
28
|
import './use-bindings-attributes';
|
|
28
29
|
createBlockEditFilter([align, anchor, customClassName, style, duotone, position, layout, contentLockUI, blockHooks, blockRenaming, childLayout].filter(Boolean));
|
|
29
|
-
createBlockListBlockFilter([align, style, color, dimensions, duotone, fontFamily, fontSize, border, position, childLayout]);
|
|
30
|
+
createBlockListBlockFilter([align, background, style, color, dimensions, duotone, fontFamily, fontSize, border, position, childLayout]);
|
|
30
31
|
createBlockSaveFilter([align, anchor, ariaLabel, customClassName, border, color, style, fontFamily, fontSize]);
|
|
31
32
|
export { useCustomSides } from './dimensions';
|
|
32
33
|
export { useLayoutClasses, useLayoutStyles } from './layout';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createBlockEditFilter","createBlockListBlockFilter","createBlockSaveFilter","align","anchor","ariaLabel","customClassName","style","color","dimensions","duotone","fontFamily","fontSize","border","position","layout","childLayout","contentLockUI","blockHooks","blockRenaming","filter","Boolean","useCustomSides","useLayoutClasses","useLayoutStyles","getBorderClassesAndStyles","useBorderProps","getShadowClassesAndStyles","getColorClassesAndStyles","useColorProps","getSpacingClassesAndStyles","getTypographyClassesAndStyles","getGapCSSValue","useCachedTruthy"],"sources":["@wordpress/block-editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateBlockEditFilter,\n\tcreateBlockListBlockFilter,\n\tcreateBlockSaveFilter,\n} from './utils';\nimport './compat';\nimport align from './align';\nimport './lock';\nimport anchor from './anchor';\nimport ariaLabel from './aria-label';\nimport customClassName from './custom-class-name';\nimport './generated-class-name';\nimport style from './style';\nimport './settings';\nimport color from './color';\nimport dimensions from './dimensions';\nimport duotone from './duotone';\nimport fontFamily from './font-family';\nimport fontSize from './font-size';\nimport border from './border';\nimport position from './position';\nimport layout from './layout';\nimport childLayout from './layout-child';\nimport contentLockUI from './content-lock-ui';\nimport './metadata';\nimport blockHooks from './block-hooks';\nimport blockRenaming from './block-renaming';\nimport './use-bindings-attributes';\n\ncreateBlockEditFilter(\n\t[\n\t\talign,\n\t\tanchor,\n\t\tcustomClassName,\n\t\tstyle,\n\t\tduotone,\n\t\tposition,\n\t\tlayout,\n\t\tcontentLockUI,\n\t\tblockHooks,\n\t\tblockRenaming,\n\t\tchildLayout,\n\t].filter( Boolean )\n);\ncreateBlockListBlockFilter( [\n\talign,\n\tstyle,\n\tcolor,\n\tdimensions,\n\tduotone,\n\tfontFamily,\n\tfontSize,\n\tborder,\n\tposition,\n\tchildLayout,\n] );\ncreateBlockSaveFilter( [\n\talign,\n\tanchor,\n\tariaLabel,\n\tcustomClassName,\n\tborder,\n\tcolor,\n\tstyle,\n\tfontFamily,\n\tfontSize,\n] );\n\nexport { useCustomSides } from './dimensions';\nexport { useLayoutClasses, useLayoutStyles } from './layout';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getShadowClassesAndStyles } from './use-shadow-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { getTypographyClassesAndStyles } from './use-typography-props';\nexport { getGapCSSValue } from './gap';\nexport { useCachedTruthy } from './use-cached-truthy';\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,qBAAqB,EACrBC,0BAA0B,EAC1BC,qBAAqB,QACf,SAAS;AAChB,OAAO,UAAU;AACjB,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAO,QAAQ;AACf,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAO,wBAAwB;AAC/B,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAO,YAAY;AACnB,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,WAAW,MAAM,gBAAgB;AACxC,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAO,YAAY;AACnB,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAO,2BAA2B;
|
|
1
|
+
{"version":3,"names":["createBlockEditFilter","createBlockListBlockFilter","createBlockSaveFilter","align","background","anchor","ariaLabel","customClassName","style","color","dimensions","duotone","fontFamily","fontSize","border","position","layout","childLayout","contentLockUI","blockHooks","blockRenaming","filter","Boolean","useCustomSides","useLayoutClasses","useLayoutStyles","getBorderClassesAndStyles","useBorderProps","getShadowClassesAndStyles","getColorClassesAndStyles","useColorProps","getSpacingClassesAndStyles","getTypographyClassesAndStyles","getGapCSSValue","useCachedTruthy"],"sources":["@wordpress/block-editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateBlockEditFilter,\n\tcreateBlockListBlockFilter,\n\tcreateBlockSaveFilter,\n} from './utils';\nimport './compat';\nimport align from './align';\nimport background from './background';\nimport './lock';\nimport anchor from './anchor';\nimport ariaLabel from './aria-label';\nimport customClassName from './custom-class-name';\nimport './generated-class-name';\nimport style from './style';\nimport './settings';\nimport color from './color';\nimport dimensions from './dimensions';\nimport duotone from './duotone';\nimport fontFamily from './font-family';\nimport fontSize from './font-size';\nimport border from './border';\nimport position from './position';\nimport layout from './layout';\nimport childLayout from './layout-child';\nimport contentLockUI from './content-lock-ui';\nimport './metadata';\nimport blockHooks from './block-hooks';\nimport blockRenaming from './block-renaming';\nimport './use-bindings-attributes';\n\ncreateBlockEditFilter(\n\t[\n\t\talign,\n\t\tanchor,\n\t\tcustomClassName,\n\t\tstyle,\n\t\tduotone,\n\t\tposition,\n\t\tlayout,\n\t\tcontentLockUI,\n\t\tblockHooks,\n\t\tblockRenaming,\n\t\tchildLayout,\n\t].filter( Boolean )\n);\ncreateBlockListBlockFilter( [\n\talign,\n\tbackground,\n\tstyle,\n\tcolor,\n\tdimensions,\n\tduotone,\n\tfontFamily,\n\tfontSize,\n\tborder,\n\tposition,\n\tchildLayout,\n] );\ncreateBlockSaveFilter( [\n\talign,\n\tanchor,\n\tariaLabel,\n\tcustomClassName,\n\tborder,\n\tcolor,\n\tstyle,\n\tfontFamily,\n\tfontSize,\n] );\n\nexport { useCustomSides } from './dimensions';\nexport { useLayoutClasses, useLayoutStyles } from './layout';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getShadowClassesAndStyles } from './use-shadow-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { getTypographyClassesAndStyles } from './use-typography-props';\nexport { getGapCSSValue } from './gap';\nexport { useCachedTruthy } from './use-cached-truthy';\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,qBAAqB,EACrBC,0BAA0B,EAC1BC,qBAAqB,QACf,SAAS;AAChB,OAAO,UAAU;AACjB,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAO,QAAQ;AACf,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAO,wBAAwB;AAC/B,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAO,YAAY;AACnB,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,OAAO,MAAM,WAAW;AAC/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ropsChildLayoutStyles({
|
|
|
23
23
|
const {
|
|
24
24
|
selfStretch,
|
|
25
25
|
flexSize,
|
|
26
|
+
columnStart,
|
|
27
|
+
rowStart,
|
|
26
28
|
columnSpan,
|
|
27
29
|
rowSpan
|
|
28
30
|
} = layout;
|
|
@@ -44,6 +46,14 @@ function useBlockPropsChildLayoutStyles({
|
|
|
44
46
|
css = `${selector} {
|
|
45
47
|
flex-grow: 1;
|
|
46
48
|
}`;
|
|
49
|
+
} else if (columnStart && columnSpan) {
|
|
50
|
+
css = `${selector} {
|
|
51
|
+
grid-column: ${columnStart} / span ${columnSpan};
|
|
52
|
+
}`;
|
|
53
|
+
} else if (columnStart) {
|
|
54
|
+
css = `${selector} {
|
|
55
|
+
grid-column: ${columnStart};
|
|
56
|
+
}`;
|
|
47
57
|
} else if (columnSpan) {
|
|
48
58
|
css = `${selector} {
|
|
49
59
|
grid-column: span ${columnSpan};
|
|
@@ -54,9 +64,11 @@ function useBlockPropsChildLayoutStyles({
|
|
|
54
64
|
* columnCount is set, the grid is responsive so a
|
|
55
65
|
* container query is needed for the span to resize.
|
|
56
66
|
*/
|
|
57
|
-
if (columnSpan && (minimumColumnWidth || !columnCount)) {
|
|
58
|
-
//
|
|
59
|
-
const columnSpanNumber = parseInt(columnSpan);
|
|
67
|
+
if ((columnSpan || columnStart) && (minimumColumnWidth || !columnCount)) {
|
|
68
|
+
// Check if columnSpan and columnStart are numbers so Math.max doesn't break.
|
|
69
|
+
const columnSpanNumber = columnSpan ? parseInt(columnSpan) : null;
|
|
70
|
+
const columnStartNumber = columnStart ? parseInt(columnStart) : null;
|
|
71
|
+
const highestNumber = Math.max(columnSpanNumber, columnStartNumber);
|
|
60
72
|
let parentColumnValue = parseFloat(minimumColumnWidth);
|
|
61
73
|
/**
|
|
62
74
|
* 12rem is the default minimumColumnWidth value.
|
|
@@ -74,14 +86,24 @@ function useBlockPropsChildLayoutStyles({
|
|
|
74
86
|
parentColumnUnit = 'rem';
|
|
75
87
|
}
|
|
76
88
|
const defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5;
|
|
77
|
-
const containerQueryValue =
|
|
89
|
+
const containerQueryValue = highestNumber * parentColumnValue + (highestNumber - 1) * defaultGapValue;
|
|
90
|
+
// If a span is set we want to preserve it as long as possible, otherwise we just reset the value.
|
|
91
|
+
const gridColumnValue = columnSpan ? '1/-1' : 'auto';
|
|
78
92
|
css += `@container (max-width: ${containerQueryValue}${parentColumnUnit}) {
|
|
79
93
|
${selector} {
|
|
80
|
-
grid-column:
|
|
94
|
+
grid-column: ${gridColumnValue};
|
|
81
95
|
}
|
|
82
96
|
}`;
|
|
83
97
|
}
|
|
84
|
-
if (rowSpan) {
|
|
98
|
+
if (rowStart && rowSpan) {
|
|
99
|
+
css += `${selector} {
|
|
100
|
+
grid-row: ${rowStart} / span ${rowSpan};
|
|
101
|
+
}`;
|
|
102
|
+
} else if (rowStart) {
|
|
103
|
+
css += `${selector} {
|
|
104
|
+
grid-row: ${rowStart};
|
|
105
|
+
}`;
|
|
106
|
+
} else if (rowSpan) {
|
|
85
107
|
css += `${selector} {
|
|
86
108
|
grid-row: span ${rowSpan};
|
|
87
109
|
}`;
|