@wordpress/block-editor 15.10.1-next.ba3aee3a2.0 → 15.10.1-next.v.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/build/components/block-bindings/attribute-control.cjs +1 -1
- package/build/components/block-bindings/attribute-control.cjs.map +1 -1
- package/build/components/block-bindings/source-fields-list.cjs +1 -1
- package/build/components/block-bindings/source-fields-list.cjs.map +1 -1
- package/build/components/block-tools/index.cjs +82 -70
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-visibility/block-visibility-info.cjs +0 -59
- package/build/components/block-visibility/block-visibility-info.cjs.map +3 -3
- package/build/components/block-visibility/constants.cjs +10 -5
- package/build/components/block-visibility/constants.cjs.map +2 -2
- package/build/components/block-visibility/index.cjs +13 -5
- package/build/components/block-visibility/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs +397 -0
- package/build/components/block-visibility/modal.cjs.map +7 -0
- package/build/components/block-visibility/toolbar.cjs +1 -1
- package/build/components/block-visibility/toolbar.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +13 -17
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/block-visibility/utils.cjs +81 -0
- package/build/components/block-visibility/utils.cjs.map +7 -0
- package/build/components/block-visibility/viewport-menu-item.cjs +61 -0
- package/build/components/block-visibility/viewport-menu-item.cjs.map +7 -0
- package/build/components/block-visibility/viewport-toolbar.cjs +89 -0
- package/build/components/block-visibility/viewport-toolbar.cjs.map +7 -0
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +1 -1
- package/build/components/inserter/menu.cjs +6 -2
- package/build/components/inserter/menu.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +2 -2
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +39 -22
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +1 -1
- package/build/components/rich-text/index.cjs.map +1 -1
- package/build/components/url-input/index.cjs +2 -0
- package/build/components/url-input/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +1 -1
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +75 -166
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/block-fields/link/index.cjs +13 -23
- package/build/hooks/block-fields/link/index.cjs.map +2 -2
- package/build/hooks/block-fields/media/index.cjs +32 -58
- package/build/hooks/block-fields/media/index.cjs.map +2 -2
- package/build/hooks/block-fields/rich-text/index.cjs +1 -5
- package/build/hooks/block-fields/rich-text/index.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +102 -0
- package/build/hooks/cross-origin-isolation.cjs.map +7 -0
- package/build/hooks/index.cjs +1 -0
- package/build/hooks/index.cjs.map +2 -2
- package/build/layouts/flex.cjs +6 -2
- package/build/layouts/flex.cjs.map +2 -2
- package/build/store/private-selectors.cjs +33 -1
- package/build/store/private-selectors.cjs.map +3 -3
- package/build/store/reducer.cjs +1 -1
- package/build/store/reducer.cjs.map +1 -1
- package/build/store/selectors.cjs +7 -8
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-bindings/attribute-control.mjs +1 -1
- package/build-module/components/block-bindings/attribute-control.mjs.map +1 -1
- package/build-module/components/block-bindings/source-fields-list.mjs +1 -1
- package/build-module/components/block-bindings/source-fields-list.mjs.map +1 -1
- package/build-module/components/block-tools/index.mjs +85 -73
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-visibility/block-visibility-info.mjs +0 -59
- package/build-module/components/block-visibility/block-visibility-info.mjs.map +3 -3
- package/build-module/components/block-visibility/constants.mjs +8 -4
- package/build-module/components/block-visibility/constants.mjs.map +2 -2
- package/build-module/components/block-visibility/index.mjs +13 -6
- package/build-module/components/block-visibility/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +384 -0
- package/build-module/components/block-visibility/modal.mjs.map +7 -0
- package/build-module/components/block-visibility/toolbar.mjs +1 -1
- package/build-module/components/block-visibility/toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +13 -13
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +55 -0
- package/build-module/components/block-visibility/utils.mjs.map +7 -0
- package/build-module/components/block-visibility/viewport-menu-item.mjs +40 -0
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +7 -0
- package/build-module/components/block-visibility/viewport-toolbar.mjs +68 -0
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +7 -0
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +1 -1
- package/build-module/components/inserter/menu.mjs +6 -2
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +2 -2
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +39 -22
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -1
- package/build-module/components/rich-text/index.mjs.map +1 -1
- package/build-module/components/url-input/index.mjs +2 -0
- package/build-module/components/url-input/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +1 -1
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +75 -166
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +13 -23
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +32 -58
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/rich-text/index.mjs +1 -5
- package/build-module/hooks/block-fields/rich-text/index.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +100 -0
- package/build-module/hooks/cross-origin-isolation.mjs.map +7 -0
- package/build-module/hooks/index.mjs +1 -0
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +6 -2
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +34 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +1 -1
- package/build-module/store/reducer.mjs.map +1 -1
- package/build-module/store/selectors.mjs +7 -8
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +4 -1
- package/build-style/content.css +4 -1
- package/build-style/style-rtl.css +48 -0
- package/build-style/style.css +48 -0
- package/package.json +39 -39
- package/src/components/block-bindings/attribute-control.js +1 -1
- package/src/components/block-bindings/source-fields-list.js +1 -1
- package/src/components/block-list/content.scss +4 -1
- package/src/components/block-tools/index.js +45 -33
- package/src/components/block-visibility/block-visibility-info.js +0 -1
- package/src/components/block-visibility/constants.js +7 -3
- package/src/components/block-visibility/index.js +21 -3
- package/src/components/block-visibility/modal.js +358 -0
- package/src/components/block-visibility/style.scss +58 -0
- package/src/components/block-visibility/test/use-block-visibility.js +12 -56
- package/src/components/block-visibility/test/utils.js +266 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/block-visibility/use-block-visibility.js +18 -21
- package/src/components/block-visibility/utils.js +95 -0
- package/src/components/block-visibility/viewport-menu-item.js +42 -0
- package/src/components/block-visibility/viewport-toolbar.js +88 -0
- package/src/components/inner-blocks/use-inner-block-template-sync.js +1 -1
- package/src/components/inserter/menu.js +6 -2
- package/src/components/list-view/block-select-button.js +2 -2
- package/src/components/list-view/block.js +47 -25
- package/src/components/rich-text/index.js +1 -1
- package/src/components/url-input/index.js +2 -0
- package/src/components/use-block-commands/index.js +4 -3
- package/src/hooks/block-fields/index.js +104 -224
- package/src/hooks/block-fields/link/index.js +13 -39
- package/src/hooks/block-fields/media/index.js +31 -90
- package/src/hooks/block-fields/rich-text/index.js +1 -5
- package/src/hooks/block-fields/styles.scss +2 -0
- package/src/hooks/cross-origin-isolation.js +143 -0
- package/src/hooks/index.js +1 -0
- package/src/layouts/flex.js +8 -3
- package/src/layouts/test/flex.js +53 -0
- package/src/store/private-selectors.js +64 -1
- package/src/store/reducer.js +1 -1
- package/src/store/selectors.js +7 -9
- package/src/store/test/private-selectors.js +80 -0
- package/src/style.scss +1 -0
- package/src/components/block-visibility/styles.scss +0 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/hooks/block-fields/media/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon,\n\t__experimentalGrid as Grid,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taudio as audioIcon,\n\timage as imageIcon,\n\tmedia as mediaIcon,\n\tvideo as videoIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaReplaceFlow from '../../../components/media-replace-flow';\nimport MediaUploadCheck from '../../../components/media-upload/check';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\nimport { getMediaSelectKey } from '../../../store/private-keys';\nimport { store as blockEditorStore } from '../../../store';\n\nfunction MediaThumbnail( { data, field, attachment } ) {\n\tconst
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,kBAA0B;AAC1B,kBAAmB;AACnB,mBAKO;AAKP,gCAA6B;AAC7B,mBAA6B;AAC7B,6CAA6C;AAC7C,0BAAkC;AAClC,mBAA0C;AAatC;AAXJ,SAAS,eAAgB,EAAE,MAAM,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon,\n\t__experimentalGrid as Grid,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taudio as audioIcon,\n\timage as imageIcon,\n\tmedia as mediaIcon,\n\tvideo as videoIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaReplaceFlow from '../../../components/media-replace-flow';\nimport MediaUploadCheck from '../../../components/media-upload/check';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\nimport { getMediaSelectKey } from '../../../store/private-keys';\nimport { store as blockEditorStore } from '../../../store';\n\nfunction MediaThumbnail( { data, field, attachment, config } ) {\n\tconst { fieldDef } = config;\n\tconst { allowedTypes = [], multiple = false } = fieldDef.args || {};\n\n\tif ( multiple ) {\n\t\treturn 'todo multiple';\n\t}\n\n\tif ( attachment?.media_type === 'image' || attachment?.poster ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-content-only-controls__media-thumbnail\">\n\t\t\t\t<img\n\t\t\t\t\talt=\"\"\n\t\t\t\t\twidth={ 24 }\n\t\t\t\t\theight={ 24 }\n\t\t\t\t\tsrc={\n\t\t\t\t\t\tattachment.media_type === 'image'\n\t\t\t\t\t\t\t? attachment.source_url\n\t\t\t\t\t\t\t: attachment.poster\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst value = field.getValue( { item: data } );\n\t\tconst url = value?.url;\n\n\t\tif ( allowedTypes[ 0 ] === 'image' && url ) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-content-only-controls__media-thumbnail\">\n\t\t\t\t\t<img alt=\"\" width={ 24 } height={ 24 } src={ url } />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tlet icon;\n\t\tif ( allowedTypes[ 0 ] === 'image' ) {\n\t\t\ticon = imageIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'video' ) {\n\t\t\ticon = videoIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'audio' ) {\n\t\t\ticon = audioIcon;\n\t\t} else {\n\t\t\ticon = mediaIcon;\n\t\t}\n\n\t\tif ( icon ) {\n\t\t\treturn <Icon icon={ icon } size={ 24 } />;\n\t\t}\n\t}\n\n\treturn <Icon icon={ mediaIcon } size={ 24 } />;\n}\n\nexport default function Media( { data, field, onChange, config = {} } ) {\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst value = field.getValue( { item: data } );\n\tconst { fieldDef } = config;\n\tconst { allowedTypes = [], multiple = false } = fieldDef.args || {};\n\n\t// Check if featured image is supported by checking if it's in the mapping\n\tconst hasFeaturedImageSupport =\n\t\tfieldDef?.mapping && 'featuredImage' in fieldDef.mapping;\n\n\tconst id = value?.id;\n\tconst url = value?.url;\n\n\tconst attachment = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tconst getMedia = settings[ getMediaSelectKey ];\n\n\t\t\tif ( ! getMedia ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getMedia( select, id );\n\t\t},\n\t\t[ id ]\n\t);\n\n\t// TODO - pluralize when multiple.\n\tlet chooseItemLabel;\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst allowedType = allowedTypes[ 0 ];\n\t\tif ( allowedType === 'image' ) {\n\t\t\tchooseItemLabel = __( 'Choose an image\u2026' );\n\t\t} else if ( allowedType === 'video' ) {\n\t\t\tchooseItemLabel = __( 'Choose a video\u2026' );\n\t\t} else if ( allowedType === 'application' ) {\n\t\t\tchooseItemLabel = __( 'Choose a file\u2026' );\n\t\t} else {\n\t\t\tchooseItemLabel = __( 'Choose a media item\u2026' );\n\t\t}\n\t} else {\n\t\tchooseItemLabel = __( 'Choose a media item\u2026' );\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<MediaReplaceFlow\n\t\t\t\tclassName=\"block-editor-content-only-controls__media-replace-flow\"\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tmediaId={ id }\n\t\t\t\tmediaURL={ url }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tonReset={ () => {\n\t\t\t\t\t// Build reset value dynamically based on mapping\n\t\t\t\t\tconst resetValue = {};\n\n\t\t\t\t\tif ( fieldDef?.mapping ) {\n\t\t\t\t\t\tObject.keys( fieldDef.mapping ).forEach( ( key ) => {\n\t\t\t\t\t\t\tresetValue[ key ] = undefined;\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\tvalue: resetValue,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\t{ ...( hasFeaturedImageSupport && {\n\t\t\t\t\tuseFeaturedImage: !! value?.featuredImage,\n\t\t\t\t\tonToggleFeaturedImage: () => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\tfeaturedImage: ! value?.featuredImage,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t} ) }\n\t\t\t\tonSelect={ ( selectedMedia ) => {\n\t\t\t\t\tif ( selectedMedia.id && selectedMedia.url ) {\n\t\t\t\t\t\t// Build new value dynamically based on what's in the mapping\n\t\t\t\t\t\tconst newValue = {\n\t\t\t\t\t\t\t...selectedMedia,\n\t\t\t\t\t\t\tmediaType: selectedMedia.media_type,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Turn off featured image when manually selecting media\n\t\t\t\t\t\tif ( hasFeaturedImageSupport ) {\n\t\t\t\t\t\t\tnewValue.featuredImage = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\trenderToggle={ ( buttonProps ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media\"\n\t\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr\"\n\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-row\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<MediaThumbnail\n\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\t\tconfig={ config }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t// TODO - truncate long titles or url smartly (e.g. show filename).\n\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw &&\n\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t? attachment?.title?.raw\n\t\t\t\t\t\t\t\t\t\t\t\t: url\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</span>\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{ ! url && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-placeholder\"\n\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t{ chooseItemLabel }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</MediaUploadCheck>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,kBAA0B;AAC1B,kBAAmB;AACnB,mBAKO;AAKP,gCAA6B;AAC7B,mBAA6B;AAC7B,6CAA6C;AAC7C,0BAAkC;AAClC,mBAA0C;AAatC;AAXJ,SAAS,eAAgB,EAAE,MAAM,OAAO,YAAY,OAAO,GAAI;AAC9D,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,EAAE,eAAe,CAAC,GAAG,WAAW,MAAM,IAAI,SAAS,QAAQ,CAAC;AAElE,MAAK,UAAW;AACf,WAAO;AAAA,EACR;AAEA,MAAK,YAAY,eAAe,WAAW,YAAY,QAAS;AAC/D,WACC,4CAAC,SAAI,WAAU,uDACd;AAAA,MAAC;AAAA;AAAA,QACA,KAAI;AAAA,QACJ,OAAQ;AAAA,QACR,QAAS;AAAA,QACT,KACC,WAAW,eAAe,UACvB,WAAW,aACX,WAAW;AAAA;AAAA,IAEhB,GACD;AAAA,EAEF;AAEA,MAAK,aAAa,WAAW,GAAI;AAChC,UAAM,QAAQ,MAAM,SAAU,EAAE,MAAM,KAAK,C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GA,cAAK,yBAA0B;AAC9B,qBAAS,gBAAgB;AAAA,UAC1B;AAEA;AAAA,YACC,MAAM,SAAU;AAAA,cACf,MAAM;AAAA,cACN,OAAO;AAAA,YACR,CAAE;AAAA,UACH;AAAA,QACD;AAAA,MACD;AAAA,MACA,cAAe,CAAE,gBAChB;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,WAAU;AAAA,UACR,GAAG;AAAA,UAEL;AAAA,YAAC,kBAAAC;AAAA,YAAA;AAAA,cACA,QAAS;AAAA,cACT,WAAY;AAAA,cACZ,iBAAgB;AAAA,cAChB,WAAU;AAAA,cAER;AAAA,uBACD,4EACC;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA;AAAA,sBACA;AAAA,sBACA;AAAA,sBACA;AAAA;AAAA,kBACD;AAAA,kBACA,4CAAC;AAAA,oBAAK,WAAU;AAAA;AAAA,oBAGd,sBAAY,OAAO,OACnB,YAAY,OAAO,QAAQ,KACxB,YAAY,OAAO,MACnB;AAAA,mBAEL;AAAA,mBACD;AAAA,gBAEC,CAAE,OACH,4EACC;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,OAAQ;AAAA,wBACP,OAAO;AAAA,wBACP,QAAQ;AAAA,sBACT;AAAA;AAAA,kBACD;AAAA,kBACA,4CAAC,UAAK,WAAU,mDACb,2BACH;AAAA,mBACD;AAAA;AAAA;AAAA,UAEF;AAAA;AAAA,MACD;AAAA;AAAA,EAEF,GACD;AAEF;",
|
|
6
6
|
"names": ["imageIcon", "videoIcon", "audioIcon", "mediaIcon", "blockEditorStore", "MediaUploadCheck", "MediaReplaceFlow", "Grid"]
|
|
7
7
|
}
|
|
@@ -55,10 +55,6 @@ function RichTextControl({
|
|
|
55
55
|
const attrValue = field.getValue({ item: data });
|
|
56
56
|
const fieldConfig = field.config || {};
|
|
57
57
|
const { clientId } = config;
|
|
58
|
-
const updateAttributes = (html) => {
|
|
59
|
-
const mappedChanges = field.setValue({ item: data, value: html });
|
|
60
|
-
onChange(mappedChanges);
|
|
61
|
-
};
|
|
62
58
|
const [selection, setSelection] = (0, import_element.useState)({
|
|
63
59
|
start: void 0,
|
|
64
60
|
end: void 0
|
|
@@ -120,7 +116,7 @@ function RichTextControl({
|
|
|
120
116
|
} = (0, import_rich_text.__unstableUseRichText)({
|
|
121
117
|
value: attrValue,
|
|
122
118
|
onChange(html, { __unstableFormats, __unstableText }) {
|
|
123
|
-
|
|
119
|
+
onChange(field.setValue({ item: data, value: html }));
|
|
124
120
|
Object.values(changeHandlers).forEach((changeHandler) => {
|
|
125
121
|
changeHandler(__unstableFormats, __unstableText);
|
|
126
122
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/hooks/block-fields/rich-text/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BaseControl, useBaseControlProps } from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRegistry } from '@wordpress/data';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { useFormatTypes } from '../../../components/rich-text/use-format-types';\nimport { getAllowedFormats } from '../../../components/rich-text/utils';\nimport { useEventListeners } from '../../../components/rich-text/event-listeners';\nimport FormatEdit from '../../../components/rich-text/format-edit';\nimport {\n\tkeyboardShortcutContext,\n\tinputEventContext,\n} from '../../../components/rich-text';\n\nexport default function RichTextControl( {\n\tdata,\n\tfield,\n\thideLabelFromVision,\n\tonChange,\n\tconfig = {},\n} ) {\n\tconst registry = useRegistry();\n\tconst attrValue = field.getValue( { item: data } );\n\tconst fieldConfig = field.config || {};\n\tconst { clientId } = config;\n\tconst
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAiD;AACjD,qBAA6B;AAC7B,kBAA4B;AAC5B,qBAAiC;AACjC,uBAGO;AAKP,8BAA+B;AAC/B,mBAAkC;AAClC,6BAAkC;AAClC,yBAAuB;AACvB,IAAAA,oBAGO;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BaseControl, useBaseControlProps } from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRegistry } from '@wordpress/data';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { useFormatTypes } from '../../../components/rich-text/use-format-types';\nimport { getAllowedFormats } from '../../../components/rich-text/utils';\nimport { useEventListeners } from '../../../components/rich-text/event-listeners';\nimport FormatEdit from '../../../components/rich-text/format-edit';\nimport {\n\tkeyboardShortcutContext,\n\tinputEventContext,\n} from '../../../components/rich-text';\n\nexport default function RichTextControl( {\n\tdata,\n\tfield,\n\thideLabelFromVision,\n\tonChange,\n\tconfig = {},\n} ) {\n\tconst registry = useRegistry();\n\tconst attrValue = field.getValue( { item: data } );\n\tconst fieldConfig = field.config || {};\n\tconst { clientId } = config;\n\tconst [ selection, setSelection ] = useState( {\n\t\tstart: undefined,\n\t\tend: undefined,\n\t} );\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst anchorRef = useRef();\n\tconst inputEvents = useRef( new Set() );\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats: fieldConfig?.allowedFormats,\n\t\tdisableFormats: fieldConfig?.disableFormats,\n\t} );\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier: field.id,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t\twithoutInteractiveFormatting: fieldConfig?.withoutInteractiveFormatting,\n\t\tdisableNoneEssentialFormatting: true,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange: onRichTextChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: attrValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tonChange( field.setValue( { item: data, value: html } ) );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange: ( start, end ) => setSelection( { start, end } ),\n\t\t__unstableIsSelected: isSelected,\n\t\tpreserveWhiteSpace: !! fieldConfig?.preserveWhiteSpace,\n\t\tplaceholder: fieldConfig?.placeholder,\n\t\t__unstableDisableFormats: fieldConfig?.disableFormats,\n\t\t__unstableDependencies: dependencies,\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\n\tconst { baseControlProps, controlProps } = useBaseControlProps( {\n\t\thideLabelFromVision: hideLabelFromVision ?? field.hideLabelFromVision,\n\t\tlabel: field.label,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onRichTextChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t\tisVisible={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t<BaseControl { ...baseControlProps }>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__rich-text\"\n\t\t\t\t\trole=\"textbox\"\n\t\t\t\t\taria-multiline={ ! fieldConfig?.disableLineBreaks }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\trichTextRef,\n\t\t\t\t\t\tuseEventListeners( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\t\tonChange: onRichTextChange,\n\t\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\t\tselectionChange: setSelection,\n\t\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\t\tdisableFormats: fieldConfig?.disableFormats,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\ttagName: 'div',\n\t\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\t\tdisableLineBreaks: fieldConfig?.disableLineBreaks,\n\t\t\t\t\t\t\tkeyboardShortcuts,\n\t\t\t\t\t\t\tinputEvents,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\tanchorRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\tonFocus={ () => setIsSelected( true ) }\n\t\t\t\t\tonBlur={ () => setIsSelected( false ) }\n\t\t\t\t\tcontentEditable\n\t\t\t\t\t{ ...controlProps }\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAiD;AACjD,qBAA6B;AAC7B,kBAA4B;AAC5B,qBAAiC;AACjC,uBAGO;AAKP,8BAA+B;AAC/B,mBAAkC;AAClC,6BAAkC;AAClC,yBAAuB;AACvB,IAAAA,oBAGO;AA2GL;AAzGa,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,CAAC;AACX,GAAI;AACH,QAAM,eAAW,yBAAY;AAC7B,QAAM,YAAY,MAAM,SAAU,EAAE,MAAM,KAAK,CAAE;AACjD,QAAM,cAAc,MAAM,UAAU,CAAC;AACrC,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,CAAE,WAAW,YAAa,QAAI,yBAAU;AAAA,IAC7C,OAAO;AAAA,IACP,KAAK;AAAA,EACN,CAAE;AACF,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAU,KAAM;AACtD,QAAM,gBAAY,uBAAO;AACzB,QAAM,kBAAc,uBAAQ,oBAAI,IAAI,CAAE;AACtC,QAAM,wBAAoB,uBAAQ,oBAAI,IAAI,CAAE;AAE5C,QAAM,6BAAyB,gCAAmB;AAAA,IACjD,gBAAgB,aAAa;AAAA,IAC7B,gBAAgB,aAAa;AAAA,EAC9B,CAAE;AAEF,QAAM;AAAA,IACL;AAAA,IACA;AA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
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// packages/block-editor/src/hooks/cross-origin-isolation.js
|
|
4
|
+
var import_hooks = require("@wordpress/hooks");
|
|
5
|
+
var import_compose = require("@wordpress/compose");
|
|
6
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
function addCrossOriginAttributes(el) {
|
|
8
|
+
if (!el.hasAttribute("crossorigin")) {
|
|
9
|
+
el.setAttribute("crossorigin", "anonymous");
|
|
10
|
+
}
|
|
11
|
+
if (el.nodeName === "IFRAME" && !el.hasAttribute("credentialless")) {
|
|
12
|
+
if (el.getAttribute("src")?.startsWith("blob:")) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
el.setAttribute("credentialless", "");
|
|
16
|
+
const origSrc = el.getAttribute("src") || "";
|
|
17
|
+
el.setAttribute("src", "");
|
|
18
|
+
el.setAttribute("src", origSrc);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (window.crossOriginIsolated) {
|
|
22
|
+
const observer = new window.MutationObserver((mutations) => {
|
|
23
|
+
mutations.forEach((mutation) => {
|
|
24
|
+
[mutation.addedNodes, mutation.target].forEach((value) => {
|
|
25
|
+
const nodes = value instanceof window.NodeList ? value : [value];
|
|
26
|
+
nodes.forEach((node) => {
|
|
27
|
+
const el = node;
|
|
28
|
+
if (!el.querySelectorAll) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
el.querySelectorAll(
|
|
32
|
+
"img,source,script,video,link,iframe"
|
|
33
|
+
).forEach((v) => {
|
|
34
|
+
addCrossOriginAttributes(v);
|
|
35
|
+
});
|
|
36
|
+
if (el.nodeName === "IFRAME") {
|
|
37
|
+
const iframeNode = el;
|
|
38
|
+
const isEmbedSandboxIframe = iframeNode.classList.contains(
|
|
39
|
+
"components-sandbox"
|
|
40
|
+
);
|
|
41
|
+
if (!isEmbedSandboxIframe) {
|
|
42
|
+
iframeNode.addEventListener("load", () => {
|
|
43
|
+
if (iframeNode.contentDocument) {
|
|
44
|
+
observer.observe(
|
|
45
|
+
iframeNode.contentDocument,
|
|
46
|
+
{
|
|
47
|
+
childList: true,
|
|
48
|
+
attributes: true,
|
|
49
|
+
subtree: true
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if ([
|
|
57
|
+
"IMG",
|
|
58
|
+
"SOURCE",
|
|
59
|
+
"SCRIPT",
|
|
60
|
+
"VIDEO",
|
|
61
|
+
"LINK",
|
|
62
|
+
"IFRAME"
|
|
63
|
+
].includes(el.nodeName)) {
|
|
64
|
+
addCrossOriginAttributes(el);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
observer.observe(document.body, {
|
|
71
|
+
childList: true,
|
|
72
|
+
attributes: true,
|
|
73
|
+
subtree: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (window.crossOriginIsolated) {
|
|
77
|
+
const supportsCredentialless = "credentialless" in window.HTMLIFrameElement.prototype;
|
|
78
|
+
const disableEmbedPreviews = (0, import_compose.createHigherOrderComponent)(
|
|
79
|
+
(BlockEdit) => (props) => {
|
|
80
|
+
if ("core/embed" !== props.name) {
|
|
81
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockEdit, { ...props });
|
|
82
|
+
}
|
|
83
|
+
const previewable = supportsCredentialless && !["facebook", "smugmug"].includes(
|
|
84
|
+
props.attributes.providerNameSlug
|
|
85
|
+
);
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
+
BlockEdit,
|
|
88
|
+
{
|
|
89
|
+
...props,
|
|
90
|
+
attributes: { ...props.attributes, previewable }
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
"withDisabledEmbedPreview"
|
|
95
|
+
);
|
|
96
|
+
(0, import_hooks.addFilter)(
|
|
97
|
+
"editor.BlockEdit",
|
|
98
|
+
"media-experiments/disable-embed-previews",
|
|
99
|
+
disableEmbedPreviews
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=cross-origin-isolation.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/cross-origin-isolation.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Adds crossorigin and credentialless attributes to elements as needed.\n *\n * @param {Element} el The element to modify.\n */\nfunction addCrossOriginAttributes( el ) {\n\t// Add the crossorigin attribute if missing.\n\tif ( ! el.hasAttribute( 'crossorigin' ) ) {\n\t\tel.setAttribute( 'crossorigin', 'anonymous' );\n\t}\n\n\t// For iframes, add the credentialless attribute.\n\tif ( el.nodeName === 'IFRAME' && ! el.hasAttribute( 'credentialless' ) ) {\n\t\t// Do not modify the iframed editor canvas.\n\t\tif ( el.getAttribute( 'src' )?.startsWith( 'blob:' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tel.setAttribute( 'credentialless', '' );\n\n\t\t// Reload the iframe to ensure the new attribute is taken into account.\n\t\tconst origSrc = el.getAttribute( 'src' ) || '';\n\t\tel.setAttribute( 'src', '' );\n\t\tel.setAttribute( 'src', origSrc );\n\t}\n}\n\n// Only add the mutation observer if the site is cross-origin isolated.\nif ( window.crossOriginIsolated ) {\n\t/*\n\t * Detects dynamically added DOM nodes that are missing the `crossorigin` attribute.\n\t */\n\tconst observer = new window.MutationObserver( ( mutations ) => {\n\t\tmutations.forEach( ( mutation ) => {\n\t\t\t[ mutation.addedNodes, mutation.target ].forEach( ( value ) => {\n\t\t\t\tconst nodes =\n\t\t\t\t\tvalue instanceof window.NodeList ? value : [ value ];\n\t\t\t\tnodes.forEach( ( node ) => {\n\t\t\t\t\tconst el = node;\n\n\t\t\t\t\tif ( ! el.querySelectorAll ) {\n\t\t\t\t\t\t// Most likely a text node.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tel.querySelectorAll(\n\t\t\t\t\t\t'img,source,script,video,link,iframe'\n\t\t\t\t\t).forEach( ( v ) => {\n\t\t\t\t\t\taddCrossOriginAttributes( v );\n\t\t\t\t\t} );\n\n\t\t\t\t\tif ( el.nodeName === 'IFRAME' ) {\n\t\t\t\t\t\tconst iframeNode = el;\n\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Sandboxed iframes should not get modified. For example embedding a tweet served in a sandboxed\n\t\t\t\t\t\t * iframe, the tweet itself would not be modified.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst isEmbedSandboxIframe =\n\t\t\t\t\t\t\tiframeNode.classList.contains(\n\t\t\t\t\t\t\t\t'components-sandbox'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( ! isEmbedSandboxIframe ) {\n\t\t\t\t\t\t\tiframeNode.addEventListener( 'load', () => {\n\t\t\t\t\t\t\t\tif ( iframeNode.contentDocument ) {\n\t\t\t\t\t\t\t\t\tobserver.observe(\n\t\t\t\t\t\t\t\t\t\tiframeNode.contentDocument,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tchildList: true,\n\t\t\t\t\t\t\t\t\t\t\tattributes: true,\n\t\t\t\t\t\t\t\t\t\t\tsubtree: true,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t'IMG',\n\t\t\t\t\t\t\t'SOURCE',\n\t\t\t\t\t\t\t'SCRIPT',\n\t\t\t\t\t\t\t'VIDEO',\n\t\t\t\t\t\t\t'LINK',\n\t\t\t\t\t\t\t'IFRAME',\n\t\t\t\t\t\t].includes( el.nodeName )\n\t\t\t\t\t) {\n\t\t\t\t\t\taddCrossOriginAttributes( el );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t} );\n\t} );\n\n\tobserver.observe( document.body, {\n\t\tchildList: true,\n\t\tattributes: true,\n\t\tsubtree: true,\n\t} );\n}\n\n// Only apply the embed preview filter when cross-origin isolated.\nif ( window.crossOriginIsolated ) {\n\tconst supportsCredentialless =\n\t\t'credentialless' in window.HTMLIFrameElement.prototype;\n\n\tconst disableEmbedPreviews = createHigherOrderComponent(\n\t\t( BlockEdit ) => ( props ) => {\n\t\t\tif ( 'core/embed' !== props.name ) {\n\t\t\t\treturn <BlockEdit { ...props } />;\n\t\t\t}\n\n\t\t\t// List of embeds that do not support a preview is from packages/block-library/src/embed/variations.js.\n\t\t\tconst previewable =\n\t\t\t\tsupportsCredentialless &&\n\t\t\t\t! [ 'facebook', 'smugmug' ].includes(\n\t\t\t\t\tprops.attributes.providerNameSlug\n\t\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, previewable } }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t\t'withDisabledEmbedPreview'\n\t);\n\n\taddFilter(\n\t\t'editor.BlockEdit',\n\t\t'media-experiments/disable-embed-previews',\n\t\tdisableEmbedPreviews\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;AAGA,mBAA0B;AAC1B,qBAA2C;AAiHhC;AA1GX,SAAS,yBAA0B,IAAK;AAEvC,MAAK,CAAE,GAAG,aAAc,aAAc,GAAI;AACzC,OAAG,aAAc,eAAe,WAAY;AAAA,EAC7C;AAGA,MAAK,GAAG,aAAa,YAAY,CAAE,GAAG,aAAc,gBAAiB,GAAI;AAExE,QAAK,GAAG,aAAc,KAAM,GAAG,WAAY,OAAQ,GAAI;AACt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AAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,EACV,CAAE;AACH;AAGA,IAAK,OAAO,qBAAsB;AACjC,QAAM,yBACL,oBAAoB,OAAO,kBAAkB;AAE9C,QAAM,2BAAuB;AAAA,IAC5B,CAAE,cAAe,CAAE,UAAW;AAC7B,UAAK,iBAAiB,MAAM,MAAO;AAClC,eAAO,4CAAC,aAAY,GAAG,OAAQ;AAAA,MAChC;AAGA,YAAM,cACL,0BACA,CAAE,CAAE,YAAY,SAAU,EAAE;AAAA,QAC3B,MAAM,WAAW;AAAA,MAClB;AAED,aACC;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACL,YAAa,EAAE,GAAG,MAAM,YAAY,YAAY;AAAA;AAAA,MACjD;AAAA,IAEF;AAAA,IACA;AAAA,EACD;AAEA;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/hooks/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ __export(hooks_exports, {
|
|
|
50
50
|
module.exports = __toCommonJS(hooks_exports);
|
|
51
51
|
var import_utils = require("./utils.cjs");
|
|
52
52
|
var import_compat = require("./compat.cjs");
|
|
53
|
+
var import_cross_origin_isolation = require("./cross-origin-isolation.cjs");
|
|
53
54
|
var import_align = __toESM(require("./align.cjs"));
|
|
54
55
|
var import_background = __toESM(require("./background.cjs"));
|
|
55
56
|
var import_lock = require("./lock.cjs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/index.js"],
|
|
4
|
-
"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 allowedBlocks from './allowed-blocks';\nimport anchor from './anchor';\nimport ariaLabel from './aria-label';\nimport './block-fields';\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 textAlign from './text-align';\nimport fitText from './fit-text';\nimport border from './border';\nimport position from './position';\nimport blockStyleVariation from './block-style-variation';\nimport layout from './layout';\nimport childLayout from './layout-child';\nimport contentLockUI from './content-lock-ui';\nimport './metadata';\nimport blockHooks from './block-hooks';\nimport blockBindingsPanel from './block-bindings';\nimport listView from './list-view';\nimport './block-renaming';\nimport './grid-visualizer';\nimport autoInspectorControls from './auto-inspector-controls';\n\ncreateBlockEditFilter(\n\t[\n\t\talign,\n\t\ttextAlign,\n\t\tanchor,\n\t\tcustomClassName,\n\t\tstyle,\n\t\tduotone,\n\t\tfitText,\n\t\tposition,\n\t\tlayout,\n\t\tcontentLockUI,\n\t\tblockHooks,\n\t\tblockBindingsPanel,\n\t\tchildLayout,\n\t\tallowedBlocks,\n\t\tlistView,\n\t\tautoInspectorControls,\n\t].filter( Boolean )\n);\ncreateBlockListBlockFilter( [\n\talign,\n\ttextAlign,\n\tbackground,\n\tstyle,\n\tcolor,\n\tdimensions,\n\tduotone,\n\tfontFamily,\n\tfontSize,\n\tfitText,\n\tborder,\n\tposition,\n\tblockStyleVariation,\n\tchildLayout,\n] );\ncreateBlockSaveFilter( [\n\talign,\n\ttextAlign,\n\tanchor,\n\tariaLabel,\n\tcustomClassName,\n\tborder,\n\tfitText,\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';\nexport { setBackgroundStyleDefaults } from './background';\nexport { useZoomOut } from './use-zoom-out';\nexport { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';\nexport { useStyleOverride } from './utils';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAIO;AACP,oBAAO;AACP,mBAAkB;AAClB,wBAAuB;AACvB,kBAAO;AACP,4BAA0B;AAC1B,oBAAmB;AACnB,wBAAsB;AACtB,0BAAO;AACP,+BAA4B;AAC5B,kCAAO;AACP,mBAAkB;AAClB,sBAAO;AACP,mBAAkB;AAClB,wBAAuB;AACvB,qBAAoB;AACpB,yBAAuB;AACvB,uBAAqB;AACrB,wBAAsB;AACtB,sBAAoB;AACpB,oBAAmB;AACnB,sBAAqB;AACrB,mCAAgC;AAChC,oBAAmB;AACnB,0BAAwB;AACxB,6BAA0B;AAC1B,sBAAO;AACP,yBAAuB;AACvB,4BAA+B;AAC/B,uBAAqB;AACrB,4BAAO;AACP,6BAAO;AACP,qCAAkC;AAoDlC,IAAAA,qBAA+B;AAC/B,IAAAC,iBAAkD;AAClD,8BAA0D;AAC1D,8BAA0C;AAC1C,6BAAwD;AACxD,+BAA2C;AAC3C,kCAA8C;AAC9C,iBAA+B;AAC/B,+BAAgC;AAChC,IAAAC,qBAA2C;AAC3C,0BAA2B;AAC3B,IAAAC,gCAAiE;AACjE,IAAAC,gBAAiC;AAAA,IA9DjC;AAAA,EACC;AAAA,IACC,aAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,yBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,eAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,+BAAAC;AAAA,EACD,EAAE,OAAQ,OAAQ;AACnB;AAAA,IACA,yCAA4B;AAAA,EAC3B,aAAAf;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAe;AAAA,EACA,aAAAZ;AAAA,EACA,aAAAa;AAAA,EACA,kBAAAC;AAAA,EACA,eAAAb;AAAA,EACA,mBAAAc;AAAA,EACA,iBAAAC;AAAA,EACA,gBAAAd;AAAA,EACA,cAAAe;AAAA,EACA,gBAAAd;AAAA,EACA,6BAAAe;AAAA,EACA,oBAAAV;AACD,CAAE;AAAA,IACF,oCAAuB;AAAA,EACtB,aAAAZ;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAqB;AAAA,EACA,yBAAApB;AAAA,EACA,cAAAkB;AAAA,EACA,gBAAAf;AAAA,EACA,aAAAW;AAAA,EACA,aAAAb;AAAA,EACA,mBAAAe;AAAA,EACA,iBAAAC;AACD,CAAE;",
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tcreateBlockEditFilter,\n\tcreateBlockListBlockFilter,\n\tcreateBlockSaveFilter,\n} from './utils';\nimport './compat';\nimport './cross-origin-isolation';\nimport align from './align';\nimport background from './background';\nimport './lock';\nimport allowedBlocks from './allowed-blocks';\nimport anchor from './anchor';\nimport ariaLabel from './aria-label';\nimport './block-fields';\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 textAlign from './text-align';\nimport fitText from './fit-text';\nimport border from './border';\nimport position from './position';\nimport blockStyleVariation from './block-style-variation';\nimport layout from './layout';\nimport childLayout from './layout-child';\nimport contentLockUI from './content-lock-ui';\nimport './metadata';\nimport blockHooks from './block-hooks';\nimport blockBindingsPanel from './block-bindings';\nimport listView from './list-view';\nimport './block-renaming';\nimport './grid-visualizer';\nimport autoInspectorControls from './auto-inspector-controls';\n\ncreateBlockEditFilter(\n\t[\n\t\talign,\n\t\ttextAlign,\n\t\tanchor,\n\t\tcustomClassName,\n\t\tstyle,\n\t\tduotone,\n\t\tfitText,\n\t\tposition,\n\t\tlayout,\n\t\tcontentLockUI,\n\t\tblockHooks,\n\t\tblockBindingsPanel,\n\t\tchildLayout,\n\t\tallowedBlocks,\n\t\tlistView,\n\t\tautoInspectorControls,\n\t].filter( Boolean )\n);\ncreateBlockListBlockFilter( [\n\talign,\n\ttextAlign,\n\tbackground,\n\tstyle,\n\tcolor,\n\tdimensions,\n\tduotone,\n\tfontFamily,\n\tfontSize,\n\tfitText,\n\tborder,\n\tposition,\n\tblockStyleVariation,\n\tchildLayout,\n] );\ncreateBlockSaveFilter( [\n\talign,\n\ttextAlign,\n\tanchor,\n\tariaLabel,\n\tcustomClassName,\n\tborder,\n\tfitText,\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';\nexport { setBackgroundStyleDefaults } from './background';\nexport { useZoomOut } from './use-zoom-out';\nexport { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';\nexport { useStyleOverride } from './utils';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,aAAAZ;AAAA,EACA,aAAAa;AAAA,EACA,kBAAAC;AAAA,EACA,eAAAb;AAAA,EACA,mBAAAc;AAAA,EACA,iBAAAC;AAAA,EACA,gBAAAd;AAAA,EACA,cAAAe;AAAA,EACA,gBAAAd;AAAA,EACA,6BAAAe;AAAA,EACA,oBAAAV;AACD,CAAE;AAAA,IACF,oCAAuB;AAAA,EACtB,aAAAZ;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAqB;AAAA,EACA,yBAAApB;AAAA,EACA,cAAAkB;AAAA,EACA,gBAAAf;AAAA,EACA,aAAAW;AAAA,EACA,aAAAb;AAAA,EACA,mBAAAe;AAAA,EACA,iBAAAC;AACD,CAAE;",
|
|
6
6
|
"names": ["import_dimensions", "import_layout", "import_background", "import_block_style_variation", "import_utils", "align", "textAlign", "anchor", "customClassName", "style", "duotone", "fitText", "position", "layout", "contentLockUI", "blockHooks", "blockBindingsPanel", "childLayout", "allowedBlocks", "listView", "autoInspectorControls", "background", "color", "dimensions", "fontFamily", "fontSize", "border", "blockStyleVariation", "ariaLabel"]
|
|
7
7
|
}
|
package/build/layouts/flex.cjs
CHANGED
|
@@ -64,7 +64,11 @@ var flex_default = {
|
|
|
64
64
|
onChange,
|
|
65
65
|
layoutBlockSupport = {}
|
|
66
66
|
}) {
|
|
67
|
-
const {
|
|
67
|
+
const {
|
|
68
|
+
allowOrientation = true,
|
|
69
|
+
allowJustification = true,
|
|
70
|
+
allowWrap = true
|
|
71
|
+
} = layoutBlockSupport;
|
|
68
72
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
69
73
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.Flex, { children: [
|
|
70
74
|
allowJustification && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -82,7 +86,7 @@ var flex_default = {
|
|
|
82
86
|
}
|
|
83
87
|
) })
|
|
84
88
|
] }),
|
|
85
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FlexWrapControl, { layout, onChange })
|
|
89
|
+
allowWrap && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FlexWrapControl, { layout, onChange })
|
|
86
90
|
] });
|
|
87
91
|
},
|
|
88
92
|
toolBarControls: function FlexLayoutToolbarControls({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/layouts/flex.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tjustifyStretch,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport {\n\tToggleControl,\n\tFlex,\n\tFlexItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors, getBlockGapCSS } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\tstretch: 'stretch',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n\tstretch: 'stretch',\n\t'space-between': 'space-between',\n};\n\nconst defaultAlignments = {\n\thorizontal: 'center',\n\tvertical: 'top',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true, allowJustification = true } =\n\t\t\tlayoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t{ allowJustification && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tconst { allowVerticalAlignment = true, allowJustification = true } =\n\t\t\tlayoutBlockSupport;\n\n\t\tif ( ! allowJustification && ! allowVerticalAlignment ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisToolbar\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowVerticalAlignment && (\n\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )\n\t\t\t\t: undefined;\n\t\tconst justifyContent = justifyContentMap[ layout.justifyContent ];\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ];\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\n\t\tlet output = '';\n\t\tconst rules = [];\n\n\t\tif ( flexWrap && flexWrap !== 'wrap' ) {\n\t\t\trules.push( `flex-wrap: ${ flexWrap }` );\n\t\t}\n\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tif ( verticalAlignment ) {\n\t\t\t\trules.push( `align-items: ${ verticalAlignment }` );\n\t\t\t}\n\t\t\tif ( justifyContent ) {\n\t\t\t\trules.push( `justify-content: ${ justifyContent }` );\n\t\t\t}\n\t\t} else {\n\t\t\tif ( verticalAlignment ) {\n\t\t\t\trules.push( `justify-content: ${ verticalAlignment }` );\n\t\t\t}\n\t\t\trules.push( 'flex-direction: column' );\n\t\t\trules.push( `align-items: ${ alignItems }` );\n\t\t}\n\n\t\tif ( rules.length ) {\n\t\t\toutput = `${ appendSelectors( selector ) } {\n\t\t\t\t${ rules.join( '; ' ) };\n\t\t\t}`;\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'flex',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\n\tconst defaultVerticalAlignment =\n\t\torientation === 'horizontal'\n\t\t\t? defaultAlignments.horizontal\n\t\t\t: defaultAlignments.vertical;\n\n\tconst { verticalAlignment = defaultVerticalAlignment } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<BlockVerticalAlignmentControl\n\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\tvalue={ verticalAlignment }\n\t\t\tcontrols={\n\t\t\t\torientation === 'horizontal'\n\t\t\t\t\t? [ 'top', 'center', 'bottom', 'stretch' ]\n\t\t\t\t\t: [ 'top', 'center', 'bottom', 'space-between' ]\n\t\t\t}\n\t\t/>\n\t);\n}\n\nconst POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t} else {\n\t\tallowedControls.push( 'stretch' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t} else {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'stretch',\n\t\t\ticon: justifyStretch,\n\t\t\tlabel: __( 'Stretch items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Justification' ) }\n\t\t\tvalue={ justifyContent }\n\t\t\tonChange={ onJustificationChange }\n\t\t\tclassName=\"block-editor-hooks__flex-layout-justification-controls\"\n\t\t>\n\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst {\n\t\torientation = 'horizontal',\n\t\tverticalAlignment,\n\t\tjustifyContent,\n\t} = layout;\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"block-editor-hooks__flex-layout-orientation-controls\"\n\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\tvalue={ orientation }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\t// Make sure the vertical alignment and justification are compatible with the new orientation.\n\t\t\t\tlet newVerticalAlignment = verticalAlignment;\n\t\t\t\tlet newJustification = justifyContent;\n\t\t\t\tif ( value === 'horizontal' ) {\n\t\t\t\t\tif ( verticalAlignment === 'space-between' ) {\n\t\t\t\t\t\tnewVerticalAlignment = 'center';\n\t\t\t\t\t}\n\t\t\t\t\tif ( justifyContent === 'stretch' ) {\n\t\t\t\t\t\tnewJustification = 'left';\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif ( verticalAlignment === 'stretch' ) {\n\t\t\t\t\t\tnewVerticalAlignment = 'top';\n\t\t\t\t\t}\n\t\t\t\t\tif ( justifyContent === 'space-between' ) {\n\t\t\t\t\t\tnewJustification = 'left';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn onChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\torientation: value,\n\t\t\t\t\tverticalAlignment: newVerticalAlignment,\n\t\t\t\t\tjustifyContent: newJustification,\n\t\t\t\t} );\n\t\t\t} }\n\t\t>\n\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tvalue=\"horizontal\"\n\t\t\t\tlabel={ __( 'Horizontal' ) }\n\t\t\t/>\n\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tvalue=\"vertical\"\n\t\t\t\tlabel={ __( 'Vertical' ) }\n\t\t\t/>\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAQO;AACP,wBAMO;AAKP,mBAAgD;AAChD,iBAA+B;AAC/B,IAAAA,qBAIO;AACP,IAAAC,gBAAwC;AACxC,yBAAmC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tjustifyStretch,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport {\n\tToggleControl,\n\tFlex,\n\tFlexItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors, getBlockGapCSS } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\tstretch: 'stretch',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n\tstretch: 'stretch',\n\t'space-between': 'space-between',\n};\n\nconst defaultAlignments = {\n\thorizontal: 'center',\n\tvertical: 'top',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst {\n\t\t\tallowOrientation = true,\n\t\t\tallowJustification = true,\n\t\t\tallowWrap = true,\n\t\t} = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t{ allowJustification && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t</Flex>\n\t\t\t\t{ allowWrap && (\n\t\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tconst { allowVerticalAlignment = true, allowJustification = true } =\n\t\t\tlayoutBlockSupport;\n\n\t\tif ( ! allowJustification && ! allowVerticalAlignment ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisToolbar\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowVerticalAlignment && (\n\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )\n\t\t\t\t: undefined;\n\t\tconst justifyContent = justifyContentMap[ layout.justifyContent ];\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ];\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\n\t\tlet output = '';\n\t\tconst rules = [];\n\n\t\tif ( flexWrap && flexWrap !== 'wrap' ) {\n\t\t\trules.push( `flex-wrap: ${ flexWrap }` );\n\t\t}\n\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tif ( verticalAlignment ) {\n\t\t\t\trules.push( `align-items: ${ verticalAlignment }` );\n\t\t\t}\n\t\t\tif ( justifyContent ) {\n\t\t\t\trules.push( `justify-content: ${ justifyContent }` );\n\t\t\t}\n\t\t} else {\n\t\t\tif ( verticalAlignment ) {\n\t\t\t\trules.push( `justify-content: ${ verticalAlignment }` );\n\t\t\t}\n\t\t\trules.push( 'flex-direction: column' );\n\t\t\trules.push( `align-items: ${ alignItems }` );\n\t\t}\n\n\t\tif ( rules.length ) {\n\t\t\toutput = `${ appendSelectors( selector ) } {\n\t\t\t\t${ rules.join( '; ' ) };\n\t\t\t}`;\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'flex',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\n\tconst defaultVerticalAlignment =\n\t\torientation === 'horizontal'\n\t\t\t? defaultAlignments.horizontal\n\t\t\t: defaultAlignments.vertical;\n\n\tconst { verticalAlignment = defaultVerticalAlignment } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<BlockVerticalAlignmentControl\n\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\tvalue={ verticalAlignment }\n\t\t\tcontrols={\n\t\t\t\torientation === 'horizontal'\n\t\t\t\t\t? [ 'top', 'center', 'bottom', 'stretch' ]\n\t\t\t\t\t: [ 'top', 'center', 'bottom', 'space-between' ]\n\t\t\t}\n\t\t/>\n\t);\n}\n\nconst POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t} else {\n\t\tallowedControls.push( 'stretch' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t} else {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'stretch',\n\t\t\ticon: justifyStretch,\n\t\t\tlabel: __( 'Stretch items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Justification' ) }\n\t\t\tvalue={ justifyContent }\n\t\t\tonChange={ onJustificationChange }\n\t\t\tclassName=\"block-editor-hooks__flex-layout-justification-controls\"\n\t\t>\n\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst {\n\t\torientation = 'horizontal',\n\t\tverticalAlignment,\n\t\tjustifyContent,\n\t} = layout;\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"block-editor-hooks__flex-layout-orientation-controls\"\n\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\tvalue={ orientation }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\t// Make sure the vertical alignment and justification are compatible with the new orientation.\n\t\t\t\tlet newVerticalAlignment = verticalAlignment;\n\t\t\t\tlet newJustification = justifyContent;\n\t\t\t\tif ( value === 'horizontal' ) {\n\t\t\t\t\tif ( verticalAlignment === 'space-between' ) {\n\t\t\t\t\t\tnewVerticalAlignment = 'center';\n\t\t\t\t\t}\n\t\t\t\t\tif ( justifyContent === 'stretch' ) {\n\t\t\t\t\t\tnewJustification = 'left';\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif ( verticalAlignment === 'stretch' ) {\n\t\t\t\t\t\tnewVerticalAlignment = 'top';\n\t\t\t\t\t}\n\t\t\t\t\tif ( justifyContent === 'space-between' ) {\n\t\t\t\t\t\tnewJustification = 'left';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn onChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\torientation: value,\n\t\t\t\t\tverticalAlignment: newVerticalAlignment,\n\t\t\t\t\tjustifyContent: newJustification,\n\t\t\t\t} );\n\t\t\t} }\n\t\t>\n\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tvalue=\"horizontal\"\n\t\t\t\tlabel={ __( 'Horizontal' ) }\n\t\t\t/>\n\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tvalue=\"vertical\"\n\t\t\t\tlabel={ __( 'Vertical' ) }\n\t\t\t/>\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAQO;AACP,wBAMO;AAKP,mBAAgD;AAChD,iBAA+B;AAC/B,IAAAA,qBAIO;AACP,IAAAC,gBAAwC;AACxC,yBAAmC;AA+ChC;AA5CH,IAAM,oBAAoB;AAAA,EACzB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,iBAAiB;AAClB;AAGA,IAAM,gBAAgB;AAAA,EACrB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACV;AAEA,IAAM,uBAAuB;AAAA,EAC5B,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,QAAQ;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rB,WAAU;AAAA,MACV,WAAQ,gBAAI,aAAc;AAAA,MAC1B,OAAQ;AAAA,MACR,UAAW,CAAE,UAAW;AAEvB,YAAI,uBAAuB;AAC3B,YAAI,mBAAmB;AACvB,YAAK,UAAU,cAAe;AAC7B,cAAK,sBAAsB,iBAAkB;AAC5C,mCAAuB;AAAA,UACxB;AACA,cAAK,mBAAmB,WAAY;AACnC,+BAAmB;AAAA,UACpB;AAAA,QACD,OAAO;AACN,cAAK,sBAAsB,WAAY;AACtC,mCAAuB;AAAA,UACxB;AACA,cAAK,mBAAmB,iBAAkB;AACzC,+BAAmB;AAAA,UACpB;AAAA,QACD;AACA,eAAO,SAAU;AAAA,UAChB,GAAG;AAAA,UACH,aAAa;AAAA,UACb,mBAAmB;AAAA,UACnB,gBAAgB;AAAA,QACjB,CAAE;AAAA,MACH;AAAA,MAEA;AAAA;AAAA,UAAC,kBAAAC;AAAA,UAAA;AAAA,YACA,MAAO;AAAA,YACP,OAAM;AAAA,YACN,WAAQ,gBAAI,YAAa;AAAA;AAAA,QAC1B;AAAA,QACA;AAAA,UAAC,kBAAAA;AAAA,UAAA;AAAA,YACA,MAAO;AAAA,YACP,OAAM;AAAA,YACN,WAAQ,gBAAI,UAAW;AAAA;AAAA,QACxB;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["import_components", "import_utils", "ToggleGroupControl", "ToggleGroupControlOptionIcon"]
|
|
7
7
|
}
|
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// packages/block-editor/src/store/private-selectors.js
|
|
21
21
|
var private_selectors_exports = {};
|
|
22
22
|
__export(private_selectors_exports, {
|
|
23
|
+
areBlocksHidden: () => areBlocksHidden,
|
|
24
|
+
areBlocksHiddenAnywhere: () => areBlocksHiddenAnywhere,
|
|
23
25
|
getAllPatterns: () => getAllPatterns,
|
|
24
26
|
getBlockRemovalRules: () => getBlockRemovalRules,
|
|
25
27
|
getBlockSettings: () => import_get_block_settings.getBlockSettings,
|
|
@@ -67,6 +69,7 @@ var import_utils = require("./utils.cjs");
|
|
|
67
69
|
var import_constants = require("./constants.cjs");
|
|
68
70
|
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
69
71
|
var import_private_keys = require("./private-keys.cjs");
|
|
72
|
+
var import_constants2 = require("../components/block-visibility/constants.cjs");
|
|
70
73
|
var import_get_block_settings = require("./get-block-settings.cjs");
|
|
71
74
|
var { isContentBlock } = (0, import_lock_unlock.unlock)(import_blocks.privateApis);
|
|
72
75
|
function isBlockInterfaceHidden(state) {
|
|
@@ -411,12 +414,39 @@ var isBlockHidden = (state, clientId) => {
|
|
|
411
414
|
}
|
|
412
415
|
if (typeof blockVisibility === "object" && blockVisibility !== null) {
|
|
413
416
|
const settings = (0, import_selectors.getSettings)(state);
|
|
414
|
-
const viewportType = settings[import_private_keys.deviceTypeKey] ??
|
|
417
|
+
const viewportType = settings[import_private_keys.deviceTypeKey] ?? import_constants2.BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
415
418
|
const viewportKey = viewportType.toLowerCase();
|
|
416
419
|
return blockVisibility?.[viewportKey] === false;
|
|
417
420
|
}
|
|
418
421
|
return false;
|
|
419
422
|
};
|
|
423
|
+
var areBlocksHidden = (state, clientIds) => {
|
|
424
|
+
if (!clientIds || clientIds.length === 0) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return clientIds.some((clientId) => isBlockHidden(state, clientId));
|
|
428
|
+
};
|
|
429
|
+
var areBlocksHiddenAnywhere = (state, clientIds) => {
|
|
430
|
+
if (!clientIds?.length) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
return clientIds.some((clientId) => {
|
|
434
|
+
if (!clientId) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
const attributes = state.blocks.attributes.get(clientId);
|
|
438
|
+
const blockVisibility = attributes?.metadata?.blockVisibility;
|
|
439
|
+
if (typeof blockVisibility === "boolean") {
|
|
440
|
+
return blockVisibility === false;
|
|
441
|
+
}
|
|
442
|
+
if ("object" !== typeof blockVisibility) {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
return import_constants2.BLOCK_VISIBILITY_VIEWPORT_ENTRIES.some(
|
|
446
|
+
([, { key }]) => blockVisibility?.[key] === false
|
|
447
|
+
);
|
|
448
|
+
});
|
|
449
|
+
};
|
|
420
450
|
function hasBlockSpotlight(state) {
|
|
421
451
|
return !!state.hasBlockSpotlight || !!state.editedContentOnlySection;
|
|
422
452
|
}
|
|
@@ -447,6 +477,8 @@ function isLockedBlock(state, clientId) {
|
|
|
447
477
|
}
|
|
448
478
|
// Annotate the CommonJS export names for ESM import in node:
|
|
449
479
|
0 && (module.exports = {
|
|
480
|
+
areBlocksHidden,
|
|
481
|
+
areBlocksHiddenAnywhere,
|
|
450
482
|
getAllPatterns,
|
|
451
483
|
getBlockRemovalRules,
|
|
452
484
|
getBlockSettings,
|