@wordpress/block-editor 12.11.0 → 12.12.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-controls/hook.js +4 -1
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +1 -1
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -0
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -2
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -0
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/dimensions-tool/index.js +22 -22
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/dimensions-tool/scale-tool.js +1 -1
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/height-control/index.js +90 -2
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +9 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/index.native.js +8 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/link-control/link-preview.js +5 -2
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/use-internal-value.js +14 -8
- package/build/components/link-control/use-internal-value.js.map +1 -1
- package/build/components/list-view/index.js +6 -5
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +2 -2
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.native.js +14 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-delete.js +1 -1
- package/build/components/rich-text/use-delete.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +25 -22
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +88 -0
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tool-selector/index.js +1 -2
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +90 -46
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-setting/index.js +4 -2
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +4 -0
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/block-rename-ui.js +5 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
- package/build/hooks/block-renaming.js.map +1 -0
- package/build/hooks/custom-class-name.js +28 -21
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +28 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +6 -6
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/metadata.js +6 -27
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/utils.js +1 -1
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +25 -3
- package/build/layouts/grid.js.map +1 -1
- package/build/layouts/utils.js +1 -1
- package/build/layouts/utils.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +13 -5
- package/build/store/actions.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +20 -0
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/pasting.js +1 -1
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -1
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +1 -1
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -0
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +22 -22
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/height-control/index.js +90 -2
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +9 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +6 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/use-internal-value.js +14 -9
- package/build-module/components/link-control/use-internal-value.js.map +1 -1
- package/build-module/components/list-view/index.js +7 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +2 -2
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +15 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +1 -1
- package/build-module/components/rich-text/use-delete.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +25 -22
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +88 -0
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tool-selector/index.js +1 -2
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +90 -46
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +4 -2
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +6 -6
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
- package/build-module/hooks/block-renaming.js.map +1 -0
- package/build-module/hooks/custom-class-name.js +28 -21
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +28 -1
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +6 -6
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/metadata.js +6 -25
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/utils.js +1 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +25 -3
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/layouts/utils.js +1 -1
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +14 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +20 -0
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/pasting.js +1 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/style-rtl.css +11 -6
- package/build-style/style.css +11 -6
- package/package.json +31 -31
- package/src/components/block-controls/hook.js +6 -3
- package/src/components/block-list/block-outline.native.js +1 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-preview/index.js +7 -1
- package/src/components/block-styles/index.js +1 -4
- package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/src/components/block-switcher/style.scss +6 -0
- package/src/components/block-tools/block-contextual-toolbar.js +1 -0
- package/src/components/block-tools/style.scss +0 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
- package/src/components/colors-gradients/style.scss +4 -2
- package/src/components/dimensions-tool/index.js +25 -25
- package/src/components/dimensions-tool/scale-tool.js +1 -1
- package/src/components/height-control/index.js +50 -2
- package/src/components/iframe/index.js +8 -1
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
- package/src/components/index.native.js +1 -0
- package/src/components/link-control/README.md +43 -0
- package/src/components/link-control/link-preview.js +11 -5
- package/src/components/link-control/style.scss +3 -3
- package/src/components/link-control/test/index.js +19 -0
- package/src/components/link-control/use-internal-value.js +14 -10
- package/src/components/list-view/index.js +13 -3
- package/src/components/media-replace-flow/index.js +9 -14
- package/src/components/provider/test/use-block-sync.js +1 -1
- package/src/components/provider/use-block-sync.js +2 -2
- package/src/components/rich-text/index.native.js +19 -3
- package/src/components/rich-text/use-delete.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +27 -24
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +22 -0
- package/src/components/tool-selector/index.js +1 -1
- package/src/components/use-block-commands/index.js +91 -46
- package/src/components/use-setting/index.js +6 -1
- package/src/components/writing-flow/use-arrow-nav.js +4 -0
- package/src/hooks/block-rename-ui.js +5 -14
- package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
- package/src/hooks/custom-class-name.js +36 -31
- package/src/hooks/duotone.js +33 -0
- package/src/hooks/index.js +1 -1
- package/src/hooks/layout.js +6 -6
- package/src/hooks/metadata.js +6 -38
- package/src/hooks/utils.js +2 -0
- package/src/layouts/grid.js +50 -2
- package/src/layouts/utils.js +2 -1
- package/src/lock-unlock.js +1 -1
- package/src/store/actions.js +25 -8
- package/src/utils/parse-css-unit-to-px.js +20 -0
- package/src/utils/pasting.js +1 -4
- package/src/utils/test/pasting.js +12 -19
- package/build/hooks/metadata-name.js.map +0 -1
- package/build-module/hooks/metadata-name.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_aspectRatioTool","_interopRequireDefault","_scaleTool","_widthHeightTool","DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","useState","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","_react","createElement","Fragment","default","options","defaultValue","nextAspectRatio","nextValue","nextScale","units","nextWidth","nextHeight","_default","exports"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,cAAcA,CAAE;EACxBC,OAAO;EACPC,KAAK,GAAG,CAAC,CAAC;EACVC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB;EAAE;EACpBC,kBAAkB,GAAG,MAAM;EAAE;EAC7BC,YAAY;EAAE;EACdC,YAAY,GAAG,MAAM;EAAE;EACvBC,YAAY,CAAE;AACf,CAAC,EAAG;EACH;EACA,MAAMC,KAAK,GACVP,KAAK,CAACO,KAAK,KAAKC,SAAS,IAAIR,KAAK,CAACO,KAAK,KAAK,MAAM,GAChD,IAAI,GACJP,KAAK,CAACO,KAAK;EACf,MAAME,MAAM,GACXT,KAAK,CAACS,MAAM,KAAKD,SAAS,IAAIR,KAAK,CAACS,MAAM,KAAK,MAAM,GAClD,IAAI,GACJT,KAAK,CAACS,MAAM;EAChB,MAAMC,WAAW,GAChBV,KAAK,CAACU,WAAW,KAAKF,SAAS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,KAAK,MAAM,GAAG,IAAI,GAAGA,SAAS;MACnDC,UAAU,GAAGA,UAAU,KAAK,MAAM,GAAG,IAAI,GAAGA,UAAU;;MAEtD;MACA,IAAK,CAAED,SAAS,EAAG;QAClB,OAAOH,SAAS,CAACnB,KAAK;MACvB,CAAC,MAAM;QACNmB,SAAS,CAACnB,KAAK,GAAGsB,SAAS;MAC5B;;MAEA;MACA,IAAK,CAAEC,UAAU,EAAG;QACnB,OAAOJ,SAAS,CAACjB,MAAM;MACxB,CAAC,MAAM;QACNiB,SAAS,CAACjB,MAAM,GAAGqB,UAAU;MAC9B;;MAEA;MACA,IAAKD,SAAS,IAAIC,UAAU,EAAG;QAC9B,OAAOJ,SAAS,CAAChB,WAAW;MAC7B,CAAC,MAAM,IAAKK,eAAe,EAAG;QAC7BW,SAAS,CAAChB,WAAW,GAAGK,eAAe;MACxC,CAAC,MAAM;QACN;QACA;QACA;MAAA;;MAGD;MACA,IAAK,CAAEA,eAAe,IAAI,CAAC,CAAEc,SAAS,KAAK,CAAC,CAAEC,UAAU,EAAG;QAC1D,OAAOJ,SAAS,CAACf,KAAK;MACvB,CAAC,MAAM,IAAKC,SAAS,EAAG;QACvBc,SAAS,CAACf,KAAK,GAAGC,SAAS;MAC5B,CAAC,MAAM;QACNc,SAAS,CAACf,KAAK,GAAGN,YAAY;QAC9BQ,YAAY,CAAER,YAAa,CAAC;MAC7B;MAEAJ,QAAQ,CAAEyB,SAAU,CAAC;IACtB;EAAG,CACH,CACA,CAAC;AAEL;AAAC,IAAAK,QAAA,GAEcjC,cAAc;AAAAkC,OAAA,CAAAV,OAAA,GAAAS,QAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","_aspectRatioTool","_interopRequireDefault","_scaleTool","_widthHeightTool","DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","useState","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","_react","createElement","Fragment","default","options","defaultValue","nextAspectRatio","nextValue","units","nextWidth","nextHeight","nextScale","_default","exports"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;A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W;IACnBX,QAAQ,EAAK6B,SAAS,IAAM;MAC3B,MAAMJ,SAAS,GAAG;QAAE,GAAG1B;MAAM,CAAC;;MAE9B;MACA8B,SAAS,GAAGA,SAAS,KAAK,MAAM,GAAG,IAAI,GAAGA,SAAS;MAEnDjB,YAAY,CAAEiB,SAAU,CAAC;;MAEzB;MACA,IAAK,CAAEA,SAAS,EAAG;QAClB,OAAOJ,SAAS,CAACf,KAAK;MACvB,CAAC,MAAM;QACNe,SAAS,CAACf,KAAK,GAAGmB,SAAS;MAC5B;MAEA7B,QAAQ,CAAEyB,SAAU,CAAC;IACtB;EAAG,CACH,CAED,CAAC;AAEL;AAAC,IAAAK,QAAA,GAEcjC,cAAc;AAAAkC,OAAA,CAAAV,OAAA,GAAAS,QAAA"}
|
|
@@ -99,7 +99,7 @@ function ScaleTool({
|
|
|
99
99
|
help: scaleHelp[displayValue],
|
|
100
100
|
value: displayValue,
|
|
101
101
|
onChange: onChange,
|
|
102
|
-
|
|
102
|
+
size: '__unstable-large'
|
|
103
103
|
}, options.map(option => (0, _react.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
104
104
|
key: option.value,
|
|
105
105
|
...option
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","DEFAULT_SCALE_OPTIONS","value","label","_x","help","__","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","useMemo","reduce","acc","option","_react","createElement","__experimentalToolsPanelItem","hasValue","onDeselect","__experimentalToggleGroupControl","isBlock","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","DEFAULT_SCALE_OPTIONS","value","label","_x","help","__","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","useMemo","reduce","acc","option","_react","createElement","__experimentalToolsPanelItem","hasValue","onDeselect","__experimentalToggleGroupControl","isBlock","size","map","__experimentalToggleGroupControlOption","key"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/scale-tool.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * The descriptions are purposely made generic as object-fit could be used for\n * any replaced element. Provide your own set of options if you need different\n * help text or labels.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element\n *\n * @type {SelectControlProps[]}\n */\nconst DEFAULT_SCALE_OPTIONS = [\n\t{\n\t\tvalue: 'fill',\n\t\tlabel: _x( 'Fill', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fill the space by stretching the content.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fit the content to the space without clipping.' ),\n\t},\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( \"Fill the space by clipping what doesn't fit.\" ),\n\t},\n\t{\n\t\tvalue: 'none',\n\t\tlabel: _x( 'None', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding.'\n\t\t),\n\t},\n\t{\n\t\tvalue: 'scale-down',\n\t\tlabel: _x( 'Scale down', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Scale down the content to fit the space if it is too big. Content that is too small will have additional padding.'\n\t\t),\n\t},\n];\n\n/**\n * @callback ScaleToolPropsOnChange\n * @param {string} nextValue New scale value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} ScaleToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {string} [value] Current scale value.\n * @property {ScaleToolPropsOnChange} [onChange] Callback to update the scale value.\n * @property {SelectControlProps[]} [options] Scale options.\n * @property {string} [defaultValue] Default scale value.\n * @property {boolean} [showControl=true] Whether to show the control.\n * @property {boolean} [isShownByDefault=true] Whether the tool panel is shown by default.\n */\n\n/**\n * A tool to select the CSS object-fit property for the image.\n *\n * @param {ScaleToolProps} props\n *\n * @return {import('react').ReactElement} The scale tool.\n */\nexport default function ScaleTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SCALE_OPTIONS,\n\tdefaultValue = DEFAULT_SCALE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n} ) {\n\t// Match the CSS default so if the value is used directly in CSS it will look correct in the control.\n\tconst displayValue = value ?? 'fill';\n\n\tconst scaleHelp = useMemo( () => {\n\t\treturn options.reduce( ( acc, option ) => {\n\t\t\tacc[ option.value ] = option.help;\n\t\t\treturn acc;\n\t\t}, {} );\n\t}, [ options ] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Scale' ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Scale' ) }\n\t\t\t\tisBlock\n\t\t\t\thelp={ scaleHelp[ displayValue ] }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t>\n\t\t\t\t{ options.map( ( option ) => (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\t{ ...option }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ToggleGroupControl>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA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
svw: {
|
|
47
|
+
max: 100,
|
|
48
|
+
step: 1
|
|
49
|
+
},
|
|
50
|
+
lvw: {
|
|
51
|
+
max: 100,
|
|
52
|
+
step: 1
|
|
53
|
+
},
|
|
54
|
+
dvw: {
|
|
55
|
+
max: 100,
|
|
56
|
+
step: 1
|
|
57
|
+
},
|
|
58
|
+
svh: {
|
|
59
|
+
max: 100,
|
|
60
|
+
step: 1
|
|
61
|
+
},
|
|
62
|
+
lvh: {
|
|
63
|
+
max: 100,
|
|
64
|
+
step: 1
|
|
65
|
+
},
|
|
66
|
+
dvh: {
|
|
67
|
+
max: 100,
|
|
68
|
+
step: 1
|
|
69
|
+
},
|
|
70
|
+
vi: {
|
|
71
|
+
max: 100,
|
|
72
|
+
step: 1
|
|
73
|
+
},
|
|
74
|
+
svi: {
|
|
75
|
+
max: 100,
|
|
76
|
+
step: 1
|
|
77
|
+
},
|
|
78
|
+
lvi: {
|
|
79
|
+
max: 100,
|
|
80
|
+
step: 1
|
|
81
|
+
},
|
|
82
|
+
dvi: {
|
|
83
|
+
max: 100,
|
|
84
|
+
step: 1
|
|
85
|
+
},
|
|
86
|
+
vb: {
|
|
87
|
+
max: 100,
|
|
88
|
+
step: 1
|
|
89
|
+
},
|
|
90
|
+
svb: {
|
|
91
|
+
max: 100,
|
|
92
|
+
step: 1
|
|
93
|
+
},
|
|
94
|
+
lvb: {
|
|
95
|
+
max: 100,
|
|
96
|
+
step: 1
|
|
97
|
+
},
|
|
98
|
+
dvb: {
|
|
99
|
+
max: 100,
|
|
100
|
+
step: 1
|
|
101
|
+
},
|
|
102
|
+
vmin: {
|
|
103
|
+
max: 100,
|
|
104
|
+
step: 1
|
|
105
|
+
},
|
|
106
|
+
svmin: {
|
|
107
|
+
max: 100,
|
|
108
|
+
step: 1
|
|
109
|
+
},
|
|
110
|
+
lvmin: {
|
|
111
|
+
max: 100,
|
|
112
|
+
step: 1
|
|
113
|
+
},
|
|
114
|
+
dvmin: {
|
|
115
|
+
max: 100,
|
|
116
|
+
step: 1
|
|
117
|
+
},
|
|
118
|
+
vmax: {
|
|
119
|
+
max: 100,
|
|
120
|
+
step: 1
|
|
121
|
+
},
|
|
122
|
+
svmax: {
|
|
123
|
+
max: 100,
|
|
124
|
+
step: 1
|
|
125
|
+
},
|
|
126
|
+
lvmax: {
|
|
127
|
+
max: 100,
|
|
128
|
+
step: 1
|
|
129
|
+
},
|
|
130
|
+
dvmax: {
|
|
131
|
+
max: 100,
|
|
132
|
+
step: 1
|
|
45
133
|
}
|
|
46
134
|
};
|
|
47
135
|
|
|
@@ -81,8 +169,8 @@ function HeightControl({
|
|
|
81
169
|
} else if (['em', 'rem'].includes(currentUnit) && newUnit === 'px') {
|
|
82
170
|
// Convert to pixel value assuming a root size of 16px.
|
|
83
171
|
onChange(Math.round(currentValue * 16) + newUnit);
|
|
84
|
-
} else if (['
|
|
85
|
-
// When converting to
|
|
172
|
+
} else if (['%', 'vw', 'svw', 'lvw', 'dvw', 'vh', 'svh', 'lvh', 'dvh', 'vi', 'svi', 'lvi', 'dvi', 'vb', 'svb', 'lvb', 'dvb', 'vmin', 'svmin', 'lvmin', 'dvmin', 'vmax', 'svmax', 'lvmax', 'dvmax'].includes(newUnit) && currentValue > 100) {
|
|
173
|
+
// When converting to `%` or viewport-relative units, cap the new value at 100.
|
|
86
174
|
onChange(100 + newUnit);
|
|
87
175
|
}
|
|
88
176
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_components","_i18n","_useSetting","_interopRequireDefault","RANGE_CONTROL_CUSTOM_SETTINGS","px","max","step","vw","vh","em","rem","HeightControl","label","__","onChange","value","_RANGE_CONTROL_CUSTOM","_RANGE_CONTROL_CUSTOM2","customRangeValue","parseFloat","units","useCustomUnits","availableUnits","useSetting","selectedUnit","useMemo","parseQuantityAndUnitFromRawValue","handleSliderChange","next","join","handleUnitChange","newUnit","currentValue","currentUnit","includes","toFixed","Math","round","_react","createElement","className","BaseControl","VisualLabel","as","Flex","FlexItem","isBlock","__experimentalUnitControl","onUnitChange","min","size","__experimentalSpacer","marginX","marginBottom","RangeControl","withInputField","__nextHasNoMarginBottom"],"sources":["@wordpress/block-editor/src/components/height-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBaseControl,\n\tRangeControl,\n\tFlex,\n\tFlexItem,\n\t__experimentalSpacer as Spacer,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nconst RANGE_CONTROL_CUSTOM_SETTINGS = {\n\tpx: { max: 1000, step: 1 },\n\t'%': { max: 100, step: 1 },\n\tvw: { max: 100, step: 1 },\n\tvh: { max: 100, step: 1 },\n\tem: { max: 50, step: 0.1 },\n\trem: { max: 50, step: 0.1 },\n};\n\n/**\n * HeightControl renders a linked unit control and range control for adjusting the height of a block.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/height-control/README.md\n *\n * @param {Object} props\n * @param {?string} props.label A label for the control.\n * @param {( value: string ) => void } props.onChange Called when the height changes.\n * @param {string} props.value The current height value.\n *\n * @return {Component} The component to be rendered.\n */\nexport default function HeightControl( {\n\tlabel = __( 'Height' ),\n\tonChange,\n\tvalue,\n} ) {\n\tconst customRangeValue = parseFloat( value );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( value ),\n\t\t\t[ value ]\n\t\t)[ 1 ] ||\n\t\tunits[ 0 ]?.value ||\n\t\t'px';\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst handleUnitChange = ( newUnit ) => {\n\t\t// Attempt to smooth over differences between currentUnit and newUnit.\n\t\t// This should slightly improve the experience of switching between unit types.\n\t\tconst [ currentValue, currentUnit ] =\n\t\t\tparseQuantityAndUnitFromRawValue( value );\n\n\t\tif ( [ 'em', 'rem' ].includes( newUnit ) && currentUnit === 'px' ) {\n\t\t\t// Convert pixel value to an approximate of the new unit, assuming a root size of 16px.\n\t\t\tonChange( ( currentValue / 16 ).toFixed( 2 ) + newUnit );\n\t\t} else if (\n\t\t\t[ 'em', 'rem' ].includes( currentUnit ) &&\n\t\t\tnewUnit === 'px'\n\t\t) {\n\t\t\t// Convert to pixel value assuming a root size of 16px.\n\t\t\tonChange( Math.round( currentValue * 16 ) + newUnit );\n\t\t} else if (\n\t\t\t[ 'vh', 'vw', '%' ].includes( newUnit ) &&\n\t\t\tcurrentValue > 100\n\t\t) {\n\t\t\t// When converting to `vh`, `vw`, or `%` units, cap the new value at 100.\n\t\t\tonChange( 100 + newUnit );\n\t\t}\n\t};\n\n\treturn (\n\t\t<fieldset className=\"block-editor-height-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.max ?? 100\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.step ?? 0.1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Spacer>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</fieldset>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAUA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAnBA;AACA;AACA;;AAcA;AACA;AACA;;AAGA,MAAMK,6BAA6B,GAAG;EACrCC,EAAE,EAAE;IAAEC,GAAG,EAAE,IAAI;IAAEC,IAAI,EAAE;EAAE,CAAC;EAC1B,GAAG,EAAE;IAAED,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EAC1BC,EAAE,EAAE;IAAEF,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EACzBE,EAAE,EAAE;IAAEH,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EACzBG,EAAE,EAAE;IAAEJ,GAAG,EAAE,EAAE;IAAEC,IAAI,EAAE;EAAI,CAAC;EAC1BI,GAAG,EAAE;IAAEL,GAAG,EAAE,EAAE;IAAEC,IAAI,EAAE;EAAI;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA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,GAAG,cAAAW,qBAAA,cAAAA,qBAAA,GAAI,GACV;IACDV,IAAI,GAAAW,sBAAA,GACHd,6BAA6B,CAAEqB,YAAY,CAAE,EAC1ClB,IAAI,cAAAW,sBAAA,cAAAA,sBAAA,GAAI,GACX;IACDsC,cAAc,EAAG,KAAO;IACxBzC,QAAQ,EAAGa,kBAAoB;IAC/B6B,uBAAuB;EAAA,CACvB,CACM,CACC,CACL,CACG,CAAC;AAEb"}
|
|
1
|
+
{"version":3,"names":["_element","require","_components","_i18n","_useSetting","_interopRequireDefault","RANGE_CONTROL_CUSTOM_SETTINGS","px","max","step","vw","vh","em","rem","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","HeightControl","label","__","onChange","value","_RANGE_CONTROL_CUSTOM","_RANGE_CONTROL_CUSTOM2","customRangeValue","parseFloat","units","useCustomUnits","availableUnits","useSetting","selectedUnit","useMemo","parseQuantityAndUnitFromRawValue","handleSliderChange","next","join","handleUnitChange","newUnit","currentValue","currentUnit","includes","toFixed","Math","round","_react","createElement","className","BaseControl","VisualLabel","as","Flex","FlexItem","isBlock","__experimentalUnitControl","onUnitChange","min","size","__experimentalSpacer","marginX","marginBottom","RangeControl","withInputField","__nextHasNoMarginBottom"],"sources":["@wordpress/block-editor/src/components/height-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBaseControl,\n\tRangeControl,\n\tFlex,\n\tFlexItem,\n\t__experimentalSpacer as Spacer,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nconst RANGE_CONTROL_CUSTOM_SETTINGS = {\n\tpx: { max: 1000, step: 1 },\n\t'%': { max: 100, step: 1 },\n\tvw: { max: 100, step: 1 },\n\tvh: { max: 100, step: 1 },\n\tem: { max: 50, step: 0.1 },\n\trem: { max: 50, step: 0.1 },\n\tsvw: { max: 100, step: 1 },\n\tlvw: { max: 100, step: 1 },\n\tdvw: { max: 100, step: 1 },\n\tsvh: { max: 100, step: 1 },\n\tlvh: { max: 100, step: 1 },\n\tdvh: { max: 100, step: 1 },\n\tvi: { max: 100, step: 1 },\n\tsvi: { max: 100, step: 1 },\n\tlvi: { max: 100, step: 1 },\n\tdvi: { max: 100, step: 1 },\n\tvb: { max: 100, step: 1 },\n\tsvb: { max: 100, step: 1 },\n\tlvb: { max: 100, step: 1 },\n\tdvb: { max: 100, step: 1 },\n\tvmin: { max: 100, step: 1 },\n\tsvmin: { max: 100, step: 1 },\n\tlvmin: { max: 100, step: 1 },\n\tdvmin: { max: 100, step: 1 },\n\tvmax: { max: 100, step: 1 },\n\tsvmax: { max: 100, step: 1 },\n\tlvmax: { max: 100, step: 1 },\n\tdvmax: { max: 100, step: 1 },\n};\n\n/**\n * HeightControl renders a linked unit control and range control for adjusting the height of a block.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/height-control/README.md\n *\n * @param {Object} props\n * @param {?string} props.label A label for the control.\n * @param {( value: string ) => void } props.onChange Called when the height changes.\n * @param {string} props.value The current height value.\n *\n * @return {Component} The component to be rendered.\n */\nexport default function HeightControl( {\n\tlabel = __( 'Height' ),\n\tonChange,\n\tvalue,\n} ) {\n\tconst customRangeValue = parseFloat( value );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( value ),\n\t\t\t[ value ]\n\t\t)[ 1 ] ||\n\t\tunits[ 0 ]?.value ||\n\t\t'px';\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst handleUnitChange = ( newUnit ) => {\n\t\t// Attempt to smooth over differences between currentUnit and newUnit.\n\t\t// This should slightly improve the experience of switching between unit types.\n\t\tconst [ currentValue, currentUnit ] =\n\t\t\tparseQuantityAndUnitFromRawValue( value );\n\n\t\tif ( [ 'em', 'rem' ].includes( newUnit ) && currentUnit === 'px' ) {\n\t\t\t// Convert pixel value to an approximate of the new unit, assuming a root size of 16px.\n\t\t\tonChange( ( currentValue / 16 ).toFixed( 2 ) + newUnit );\n\t\t} else if (\n\t\t\t[ 'em', 'rem' ].includes( currentUnit ) &&\n\t\t\tnewUnit === 'px'\n\t\t) {\n\t\t\t// Convert to pixel value assuming a root size of 16px.\n\t\t\tonChange( Math.round( currentValue * 16 ) + newUnit );\n\t\t} else if (\n\t\t\t[\n\t\t\t\t'%',\n\t\t\t\t'vw',\n\t\t\t\t'svw',\n\t\t\t\t'lvw',\n\t\t\t\t'dvw',\n\t\t\t\t'vh',\n\t\t\t\t'svh',\n\t\t\t\t'lvh',\n\t\t\t\t'dvh',\n\t\t\t\t'vi',\n\t\t\t\t'svi',\n\t\t\t\t'lvi',\n\t\t\t\t'dvi',\n\t\t\t\t'vb',\n\t\t\t\t'svb',\n\t\t\t\t'lvb',\n\t\t\t\t'dvb',\n\t\t\t\t'vmin',\n\t\t\t\t'svmin',\n\t\t\t\t'lvmin',\n\t\t\t\t'dvmin',\n\t\t\t\t'vmax',\n\t\t\t\t'svmax',\n\t\t\t\t'lvmax',\n\t\t\t\t'dvmax',\n\t\t\t].includes( newUnit ) &&\n\t\t\tcurrentValue > 100\n\t\t) {\n\t\t\t// When converting to `%` or viewport-relative units, cap the new value at 100.\n\t\t\tonChange( 100 + newUnit );\n\t\t}\n\t};\n\n\treturn (\n\t\t<fieldset className=\"block-editor-height-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.max ?? 100\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.step ?? 0.1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Spacer>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</fieldset>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAUA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAnBA;AACA;AACA;;AAcA;AACA;AACA;;AAGA,MAAMK,6BAA6B,GAAG;EACrCC,EAAE,EAAE;IAAEC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AA,qBAAA,GAAI,GACV;IACDhC,IAAI,GAAAiC,sBAAA,GACHpC,6BAA6B,CAAE2C,YAAY,CAAE,EAC1CxC,IAAI,cAAAiC,sBAAA,cAAAA,sBAAA,GAAI,GACX;IACDsC,cAAc,EAAG,KAAO;IACxBzC,QAAQ,EAAGa,kBAAoB;IAC/B6B,uBAAuB;EAAA,CACvB,CACM,CACC,CACL,CACG,CAAC;AAEb"}
|
|
@@ -33,7 +33,15 @@ function bubbleEvent(event, Constructor, frame) {
|
|
|
33
33
|
for (const key in event) {
|
|
34
34
|
init[key] = event[key];
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
// Check if the event is a MouseEvent generated within the iframe.
|
|
38
|
+
// If so, adjust the coordinates to be relative to the position of
|
|
39
|
+
// the iframe. This ensures that components such as Draggable
|
|
40
|
+
// receive coordinates relative to the window, instead of relative
|
|
41
|
+
// to the iframe. Without this, the Draggable event handler would
|
|
42
|
+
// result in components "jumping" position as soon as the user
|
|
43
|
+
// drags over the iframe.
|
|
44
|
+
if (event instanceof frame.contentDocument.defaultView.MouseEvent) {
|
|
37
45
|
const rect = frame.getBoundingClientRect();
|
|
38
46
|
init.clientX += rect.left;
|
|
39
47
|
init.clientY += rect.top;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_useCompatibilityStyles","_store","bubbleEvent","event","Constructor","frame","init","key","ownerDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","useRefEffect","body","frameElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","resolvedAssets","isPreviewMode","useSelect","select","settings","blockEditorStore","getSettings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","useState","bodyClasses","setBodyClasses","compatStyles","useCompatibilityStyles","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","useResizeObserver","setRef","node","_load","contentDocument","iFrameDocument","preventFileDropDefault","onLoad","documentElement","Array","from","classList","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","html","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","useEffect","marginFromScaling","_react","createElement","Fragment","style","border","marginTop","marginBottom","transform","transition","title","__","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","createPortal","className","classnames","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","forwardRef","exports","default"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\tif ( event instanceof frame.ownerDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( ( body ) => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\tbody.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\tbody.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of compatStyles ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\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\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\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ACPjB,cAAc,CAAC4D,eAChB,CACM,CAAC,EACP1C,QAAQ,IAAI,CAAC,IAAI6B,KAClB,CAAC;AAEL;AAEA,SAASiE,aAAaA,CAAEvF,KAAK,EAAED,GAAG,EAAG;EACpC,MAAMyF,aAAa,GAAG,IAAArF,eAAS,EAC5BC,MAAM,IACPA,MAAM,CAAEE,YAAiB,CAAC,CAACC,WAAW,CAAC,CAAC,CAACkF,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAtB,MAAA,CAAAC,aAAA,EAAC7E,MAAM;IAAA,GAAMU,KAAK;IAAGF,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAAC,IAAA2F,QAAA,GAEc,IAAAC,mBAAU,EAAEJ,aAAc,CAAC;AAAAK,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_useCompatibilityStyles","_store","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","useRefEffect","body","frameElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","resolvedAssets","isPreviewMode","useSelect","select","settings","blockEditorStore","getSettings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","useState","bodyClasses","setBodyClasses","compatStyles","useCompatibilityStyles","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","useResizeObserver","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","documentElement","Array","from","classList","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","html","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","useEffect","marginFromScaling","_react","createElement","Fragment","style","border","marginTop","marginBottom","transform","transition","title","__","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","createPortal","className","classnames","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","forwardRef","exports","default"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( ( body ) => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\tbody.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\tbody.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of compatStyles ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\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\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;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,QACY,CACV,CAAC,EACPjB,cAAc,CAAC4D,eAChB,CACM,CAAC,EACP1C,QAAQ,IAAI,CAAC,IAAI6B,KAClB,CAAC;AAEL;AAEA,SAASiE,aAAaA,CAAEvF,KAAK,EAAED,GAAG,EAAG;EACpC,MAAMyF,aAAa,GAAG,IAAArF,eAAS,EAC5BC,MAAM,IACPA,MAAM,CAAEE,YAAiB,CAAC,CAACC,WAAW,CAAC,CAAC,CAACkF,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAtB,MAAA,CAAAC,aAAA,EAAC7E,MAAM;IAAA,GAAMU,KAAK;IAAGF,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAAC,IAAA2F,QAAA,GAEc,IAAAC,mBAAU,EAAEJ,aAAc,CAAC;AAAAK,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
|
|
@@ -83,9 +83,6 @@ function AspectRatioDropdown({
|
|
|
83
83
|
},
|
|
84
84
|
value: aspect,
|
|
85
85
|
aspectRatios: [{
|
|
86
|
-
title: (0, _i18n.__)('16:10'),
|
|
87
|
-
aspect: 16 / 10
|
|
88
|
-
}, {
|
|
89
86
|
title: (0, _i18n.__)('16:9'),
|
|
90
87
|
aspect: 16 / 9
|
|
91
88
|
}, {
|
|
@@ -104,9 +101,6 @@ function AspectRatioDropdown({
|
|
|
104
101
|
},
|
|
105
102
|
value: aspect,
|
|
106
103
|
aspectRatios: [{
|
|
107
|
-
title: (0, _i18n.__)('10:16'),
|
|
108
|
-
aspect: 10 / 16
|
|
109
|
-
}, {
|
|
110
104
|
title: (0, _i18n.__)('9:16'),
|
|
111
105
|
aspect: 9 / 16
|
|
112
106
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_components","_i18n","_constants","_context","AspectGroup","aspectRatios","isDisabled","label","onClick","value","_react","createElement","MenuGroup","map","title","aspect","MenuItem","key","disabled","role","isSelected","icon","check","undefined","AspectRatioDropdown","toggleProps","isInProgress","setAspect","defaultAspect","useImageEditingContext","DropdownMenu","aspectRatioIcon","__","popoverProps","POPOVER_PROPS","className","onClose","Fragment","newAspect"],"sources":["@wordpress/block-editor/src/components/image-editor/aspect-ratio-dropdown.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { check, aspectRatio as aspectRatioIcon } from '@wordpress/icons';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { POPOVER_PROPS } from './constants';\nimport { useImageEditingContext } from './context';\n\nfunction AspectGroup( { aspectRatios, isDisabled, label, onClick, value } ) {\n\treturn (\n\t\t<MenuGroup label={ label }>\n\t\t\t{ aspectRatios.map( ( { title, aspect } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tkey={ aspect }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick( aspect );\n\t\t\t\t\t} }\n\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\tisSelected={ aspect === value }\n\t\t\t\t\ticon={ aspect === value ? check : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n\nexport default function AspectRatioDropdown( { toggleProps } ) {\n\tconst { isInProgress, aspect, setAspect, defaultAspect } =\n\t\tuseImageEditingContext();\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ aspectRatioIcon }\n\t\t\tlabel={ __( 'Aspect Ratio' ) }\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tclassName=\"wp-block-image__aspect-ratio\"\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t// All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Original' ),\n\t\t\t\t\t\t\t\taspect: defaultAspect,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Square' ),\n\t\t\t\t\t\t\t\taspect: 1,\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\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Landscape' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '16:
|
|
1
|
+
{"version":3,"names":["_icons","require","_components","_i18n","_constants","_context","AspectGroup","aspectRatios","isDisabled","label","onClick","value","_react","createElement","MenuGroup","map","title","aspect","MenuItem","key","disabled","role","isSelected","icon","check","undefined","AspectRatioDropdown","toggleProps","isInProgress","setAspect","defaultAspect","useImageEditingContext","DropdownMenu","aspectRatioIcon","__","popoverProps","POPOVER_PROPS","className","onClose","Fragment","newAspect"],"sources":["@wordpress/block-editor/src/components/image-editor/aspect-ratio-dropdown.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { check, aspectRatio as aspectRatioIcon } from '@wordpress/icons';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { POPOVER_PROPS } from './constants';\nimport { useImageEditingContext } from './context';\n\nfunction AspectGroup( { aspectRatios, isDisabled, label, onClick, value } ) {\n\treturn (\n\t\t<MenuGroup label={ label }>\n\t\t\t{ aspectRatios.map( ( { title, aspect } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tkey={ aspect }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick( aspect );\n\t\t\t\t\t} }\n\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\tisSelected={ aspect === value }\n\t\t\t\t\ticon={ aspect === value ? check : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n\nexport default function AspectRatioDropdown( { toggleProps } ) {\n\tconst { isInProgress, aspect, setAspect, defaultAspect } =\n\t\tuseImageEditingContext();\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ aspectRatioIcon }\n\t\t\tlabel={ __( 'Aspect Ratio' ) }\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tclassName=\"wp-block-image__aspect-ratio\"\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t// All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Original' ),\n\t\t\t\t\t\t\t\taspect: defaultAspect,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Square' ),\n\t\t\t\t\t\t\t\taspect: 1,\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\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Landscape' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '16:9' ),\n\t\t\t\t\t\t\t\taspect: 16 / 9,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '4:3' ),\n\t\t\t\t\t\t\t\taspect: 4 / 3,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '3:2' ),\n\t\t\t\t\t\t\t\taspect: 3 / 2,\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\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Portrait' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '9:16' ),\n\t\t\t\t\t\t\t\taspect: 9 / 16,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '3:4' ),\n\t\t\t\t\t\t\t\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AAE,IAAAkB,QAAE,EAAE,KAAM,CAAC;MAClBjB,MAAM,EAAE,CAAC,GAAG;IACb,CAAC;EACC,CACH,CAAC,EACF,IAAAL,MAAA,CAAAC,aAAA,EAACP,WAAW;IACXG,KAAK,EAAG,IAAAyB,QAAE,EAAE,UAAW,CAAG;IAC1B1B,UAAU,EAAGoB,YAAc;IAC3BlB,OAAO,EAAK8B,SAAS,IAAM;MAC1BX,SAAS,CAAEW,SAAU,CAAC;MACtBF,OAAO,CAAC,CAAC;IACV,CAAG;IACH3B,KAAK,EAAGM,MAAQ;IAChBV,YAAY,EAAG,CACd;MACCS,KAAK,EAAE,IAAAkB,QAAE,EAAE,MAAO,CAAC;MACnBjB,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAE,IAAAkB,QAAE,EAAE,KAAM,CAAC;MAClBjB,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAE,IAAAkB,QAAE,EAAE,KAAM,CAAC;MAClBjB,MAAM,EAAE,CAAC,GAAG;IACb,CAAC;EACC,CACH,CACA,CAEU,CAAC;AAEjB"}
|
|
@@ -55,6 +55,7 @@ var _exportNames = {
|
|
|
55
55
|
Warning: true,
|
|
56
56
|
ContrastChecker: true,
|
|
57
57
|
useMultipleOriginColorsAndGradients: true,
|
|
58
|
+
UnsupportedBlockDetails: true,
|
|
58
59
|
BottomSheetSettings: true,
|
|
59
60
|
BlockSettingsButton: true,
|
|
60
61
|
blockSettingsScreens: true,
|
|
@@ -387,6 +388,12 @@ Object.defineProperty(exports, "URLInput", {
|
|
|
387
388
|
return _urlInput.default;
|
|
388
389
|
}
|
|
389
390
|
});
|
|
391
|
+
Object.defineProperty(exports, "UnsupportedBlockDetails", {
|
|
392
|
+
enumerable: true,
|
|
393
|
+
get: function () {
|
|
394
|
+
return _unsupportedBlockDetails.default;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
390
397
|
Object.defineProperty(exports, "VIDEO_ASPECT_RATIO", {
|
|
391
398
|
enumerable: true,
|
|
392
399
|
get: function () {
|
|
@@ -556,6 +563,7 @@ var _recursionProvider = require("./recursion-provider");
|
|
|
556
563
|
var _warning = _interopRequireDefault(require("./warning"));
|
|
557
564
|
var _contrastChecker = _interopRequireDefault(require("./contrast-checker"));
|
|
558
565
|
var _useMultipleOriginColorsAndGradients = _interopRequireDefault(require("./colors-gradients/use-multiple-origin-colors-and-gradients"));
|
|
566
|
+
var _unsupportedBlockDetails = _interopRequireDefault(require("./unsupported-block-details"));
|
|
559
567
|
var _blockSettings = require("./block-settings");
|
|
560
568
|
var _videoPlayer = _interopRequireWildcard(require("./video-player"));
|
|
561
569
|
var _utils = require("./spacing-sizes-control/utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockAlignmentControl","require","_blockContext","_blockControls","_interopRequireWildcard","_blockEdit","_blockIcon","_interopRequireDefault","_blockVerticalAlignmentControl","_colors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_gradients","_fontSizes","_alignmentControl","_innerBlocks","_inspectorControls","_justifyContentControl","_lineHeightControl","_blockHeadingLevelDropdown","_plainText","_richText","_mediaReplaceFlow","_mediaPlaceholder","_mediaUpload","_constants","_mediaUploadProgress","_blockMediaUpdateProgress","_urlInput","_blockInvalidWarning","_blockCaption","_caption","_panelColorSettings","_panelColorGradientSettings","_useSetting","_recursionProvider","_warning","_contrastChecker","_useMultipleOriginColorsAndGradients","_blockSettings","_videoPlayer","_utils","_blockList","_blockMover","_blockToolbar","_blockVariationPicker","_blockStyles","_defaultBlockAppender","_editorStyles","_inserter","_useBlockProps","_floatingToolbar","_provider","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set"],"sources":["@wordpress/block-editor/src/components/index.native.js"],"sourcesContent":["// Block Creation Components.\nexport {\n\tBlockAlignmentControl,\n\tBlockAlignmentToolbar,\n} from './block-alignment-control';\nexport { BlockContextProvider } from './block-context';\nexport {\n\tdefault as BlockControls,\n\tBlockFormatControls,\n} from './block-controls';\nexport { default as BlockEdit, useBlockEditContext } from './block-edit';\nexport { default as BlockIcon } from './block-icon';\nexport {\n\tBlockVerticalAlignmentToolbar,\n\tBlockVerticalAlignmentControl,\n} from './block-vertical-alignment-control';\nexport * from './colors';\nexport * from './gradients';\nexport * from './font-sizes';\nexport { AlignmentControl, AlignmentToolbar } from './alignment-control';\nexport { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';\nexport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from './inspector-controls';\nexport {\n\tJustifyToolbar,\n\tJustifyContentControl,\n} from './justify-content-control';\nexport { default as LineHeightControl } from './line-height-control';\nexport { default as HeadingLevelDropdown } from './block-heading-level-dropdown';\nexport { default as PlainText } from './plain-text';\nexport {\n\tdefault as RichText,\n\tRichTextShortcut,\n\tRichTextToolbarButton,\n\t__unstableRichTextInputEvent,\n} from './rich-text';\nexport { default as MediaReplaceFlow } from './media-replace-flow';\nexport { default as MediaPlaceholder } from './media-placeholder';\nexport { default as MediaUpload } from './media-upload';\nexport {\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n\tMEDIA_TYPE_ANY,\n} from './media-upload/constants';\nexport {\n\tdefault as MediaUploadProgress,\n\tMEDIA_UPLOAD_STATE_UPLOADING,\n\tMEDIA_UPLOAD_STATE_SUCCEEDED,\n\tMEDIA_UPLOAD_STATE_FAILED,\n\tMEDIA_UPLOAD_STATE_RESET,\n} from './media-upload-progress';\nexport { default as BlockMediaUpdateProgress } from './block-media-update-progress';\nexport { default as URLInput } from './url-input';\nexport { default as BlockInvalidWarning } from './block-list/block-invalid-warning';\nexport { default as BlockCaption } from './block-caption';\nexport { default as Caption } from './caption';\nexport { default as PanelColorSettings } from './panel-color-settings';\nexport { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';\nexport { default as useSetting } from './use-setting';\nexport {\n\tRecursionProvider as __experimentalRecursionProvider,\n\tuseHasRecursion as __experimentalUseHasRecursion,\n} from './recursion-provider';\nexport { default as Warning } from './warning';\nexport { default as ContrastChecker } from './contrast-checker';\nexport { default as useMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';\n\nexport {\n\tBottomSheetSettings,\n\tBlockSettingsButton,\n\tblockSettingsScreens,\n} from './block-settings';\nexport { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';\n\nexport {\n\tgetSpacingPresetCssVar,\n\tgetCustomValueFromPreset,\n\tisValueSpacingPreset,\n} from './spacing-sizes-control/utils';\n// Content Related Components.\nexport { default as BlockList } from './block-list';\nexport { default as BlockMover } from './block-mover';\nexport { default as BlockToolbar } from './block-toolbar';\nexport { default as BlockVariationPicker } from './block-variation-picker';\nexport { default as BlockStyles } from './block-styles';\nexport { default as DefaultBlockAppender } from './default-block-appender';\nexport { default as __unstableEditorStyles } from './editor-styles';\nexport { default as Inserter } from './inserter';\nexport { useBlockProps } from './block-list/use-block-props';\nexport { default as FloatingToolbar } from './floating-toolbar';\n\n// State Related Components.\nexport { default as BlockEditorProvider } from './provider';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_blockAlignmentControl","require","_blockContext","_blockControls","_interopRequireWildcard","_blockEdit","_blockIcon","_interopRequireDefault","_blockVerticalAlignmentControl","_colors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_gradients","_fontSizes","_alignmentControl","_innerBlocks","_inspectorControls","_justifyContentControl","_lineHeightControl","_blockHeadingLevelDropdown","_plainText","_richText","_mediaReplaceFlow","_mediaPlaceholder","_mediaUpload","_constants","_mediaUploadProgress","_blockMediaUpdateProgress","_urlInput","_blockInvalidWarning","_blockCaption","_caption","_panelColorSettings","_panelColorGradientSettings","_useSetting","_recursionProvider","_warning","_contrastChecker","_useMultipleOriginColorsAndGradients","_unsupportedBlockDetails","_blockSettings","_videoPlayer","_utils","_blockList","_blockMover","_blockToolbar","_blockVariationPicker","_blockStyles","_defaultBlockAppender","_editorStyles","_inserter","_useBlockProps","_floatingToolbar","_provider","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set"],"sources":["@wordpress/block-editor/src/components/index.native.js"],"sourcesContent":["// Block Creation Components.\nexport {\n\tBlockAlignmentControl,\n\tBlockAlignmentToolbar,\n} from './block-alignment-control';\nexport { BlockContextProvider } from './block-context';\nexport {\n\tdefault as BlockControls,\n\tBlockFormatControls,\n} from './block-controls';\nexport { default as BlockEdit, useBlockEditContext } from './block-edit';\nexport { default as BlockIcon } from './block-icon';\nexport {\n\tBlockVerticalAlignmentToolbar,\n\tBlockVerticalAlignmentControl,\n} from './block-vertical-alignment-control';\nexport * from './colors';\nexport * from './gradients';\nexport * from './font-sizes';\nexport { AlignmentControl, AlignmentToolbar } from './alignment-control';\nexport { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';\nexport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from './inspector-controls';\nexport {\n\tJustifyToolbar,\n\tJustifyContentControl,\n} from './justify-content-control';\nexport { default as LineHeightControl } from './line-height-control';\nexport { default as HeadingLevelDropdown } from './block-heading-level-dropdown';\nexport { default as PlainText } from './plain-text';\nexport {\n\tdefault as RichText,\n\tRichTextShortcut,\n\tRichTextToolbarButton,\n\t__unstableRichTextInputEvent,\n} from './rich-text';\nexport { default as MediaReplaceFlow } from './media-replace-flow';\nexport { default as MediaPlaceholder } from './media-placeholder';\nexport { default as MediaUpload } from './media-upload';\nexport {\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n\tMEDIA_TYPE_ANY,\n} from './media-upload/constants';\nexport {\n\tdefault as MediaUploadProgress,\n\tMEDIA_UPLOAD_STATE_UPLOADING,\n\tMEDIA_UPLOAD_STATE_SUCCEEDED,\n\tMEDIA_UPLOAD_STATE_FAILED,\n\tMEDIA_UPLOAD_STATE_RESET,\n} from './media-upload-progress';\nexport { default as BlockMediaUpdateProgress } from './block-media-update-progress';\nexport { default as URLInput } from './url-input';\nexport { default as BlockInvalidWarning } from './block-list/block-invalid-warning';\nexport { default as BlockCaption } from './block-caption';\nexport { default as Caption } from './caption';\nexport { default as PanelColorSettings } from './panel-color-settings';\nexport { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';\nexport { default as useSetting } from './use-setting';\nexport {\n\tRecursionProvider as __experimentalRecursionProvider,\n\tuseHasRecursion as __experimentalUseHasRecursion,\n} from './recursion-provider';\nexport { default as Warning } from './warning';\nexport { default as ContrastChecker } from './contrast-checker';\nexport { default as useMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';\nexport { default as UnsupportedBlockDetails } from './unsupported-block-details';\n\nexport {\n\tBottomSheetSettings,\n\tBlockSettingsButton,\n\tblockSettingsScreens,\n} from './block-settings';\nexport { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';\n\nexport {\n\tgetSpacingPresetCssVar,\n\tgetCustomValueFromPreset,\n\tisValueSpacingPreset,\n} from './spacing-sizes-control/utils';\n// Content Related Components.\nexport { default as BlockList } from './block-list';\nexport { default as BlockMover } from './block-mover';\nexport { default as BlockToolbar } from './block-toolbar';\nexport { default as BlockVariationPicker } from './block-variation-picker';\nexport { default as BlockStyles } from './block-styles';\nexport { default as DefaultBlockAppender } from './default-block-appender';\nexport { default as __unstableEditorStyles } from './editor-styles';\nexport { default as Inserter } from './inserter';\nexport { useBlockProps } from './block-list/use-block-props';\nexport { default as FloatingToolbar } from './floating-toolbar';\n\n// State Related Components.\nexport { default as BlockEditorProvider } from './provider';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAAgE,IAAA,YAAAH,MAAA,CAAA7D,GAAA,IAAAwD,GAAA,CAAAxD,GAAA,SAAA6D,MAAA,CAAAH,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAM,GAAA,CAAAT,GAAA,EAAAK,MAAA,YAAAA,MAAA"}
|
|
@@ -84,10 +84,13 @@ function LinkPreview({
|
|
|
84
84
|
})
|
|
85
85
|
}, icon), (0, _react.createElement)("span", {
|
|
86
86
|
className: "block-editor-link-control__search-item-details"
|
|
87
|
-
}, !isEmptyURL ? (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.
|
|
87
|
+
}, !isEmptyURL ? (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.Tooltip, {
|
|
88
|
+
text: value.url,
|
|
89
|
+
placement: "bottom-start"
|
|
90
|
+
}, (0, _react.createElement)(_components.ExternalLink, {
|
|
88
91
|
className: "block-editor-link-control__search-item-title",
|
|
89
92
|
href: value.url
|
|
90
|
-
}, displayTitle), value?.url && displayTitle !== displayURL && (0, _react.createElement)("span", {
|
|
93
|
+
}, displayTitle)), value?.url && displayTitle !== displayURL && (0, _react.createElement)("span", {
|
|
91
94
|
className: "block-editor-link-control__search-item-info"
|
|
92
95
|
}, displayURL)) : (0, _react.createElement)("span", {
|
|
93
96
|
className: "block-editor-link-control__search-item-error-notice"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_components","_url","_icons","_dom","_viewerSlot","_useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","additionalControls","showRichPreviews","url","richData","isFetching","useRichUrlData","hasRichData","Object","keys","length","displayURL","filterURLForDisplay","safeDecodeURI","isEmptyURL","displayTitle","stripHTML","title","icon","_react","createElement","src","alt","Icon","info","size","globe","__","className","classnames","Fragment","ExternalLink","href","Button","edit","label","onClick","iconSize","linkOff","ViewerSlot","fillProps","image","description","__experimentalText","truncate","numberOfLines"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n\tadditionalControls,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\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\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t{ displayURL }\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) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\n\t\t\t{ !! (\n\t\t\t\t( hasRichData &&\n\t\t\t\t\t( richData?.image || richData?.description ) ) ||\n\t\t\t\tisFetching\n\t\t\t) && (\n\t\t\t\t<div className=\"block-editor-link-control__search-item-bottom\">\n\t\t\t\t\t{ ( richData?.image || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.image }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-image',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.image,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.image && (\n\t\t\t\t\t\t\t\t<img src={ richData?.image } alt=\"\" />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ( richData?.description || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.description }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-description',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.description,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.description && (\n\t\t\t\t\t\t\t\t<Text truncate numberOfLines=\"2\">\n\t\t\t\t\t\t\t\t\t{ richData.description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ additionalControls && additionalControls() }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AAEA,IAAAO,eAAA,GAAAR,sBAAA,CAAAC,OAAA;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAKe,SAASQ,WAAWA,CAAE;EACpCC,KAAK;EACLC,WAAW;EACXC,eAAe,GAAG,KAAK;EACvBC,gBAAgB,GAAG,KAAK;EACxBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH;EACA,MAAMC,gBAAgB,GAAGJ,eAAe,GAAGF,KAAK,EAAEO,GAAG,GAAG,IAAI;EAE5D,MAAM;IAAEC,QAAQ;IAAEC;EAAW,CAAC,GAAG,IAAAC,uBAAc,EAAEJ,gBAAiB,CAAC;;EAEnE;EACA,MAAMK,WAAW,GAAGH,QAAQ,IAAII,MAAM,CAACC,IAAI,CAAEL,QAAS,CAAC,CAACM,MAAM;EAE9D,MAAMC,UAAU,GACbf,KAAK,IAAI,IAAAgB,wBAAmB,EAAE,IAAAC,kBAAa,EAAEjB,KAAK,CAACO,GAAI,CAAC,EAAE,EAAG,CAAC,IAChE,EAAE;;EAEH;EACA,MAAMW,UAAU,GAAG,CAAElB,KAAK,EAAEO,GAAG,EAAEO,MAAM;EAEvC,MAAMK,YAAY,GACjB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c,MAAA,CAAAC,aAAA;IAAKQ,SAAS,EAAC;EAA+C,GAC3D,CAAExB,QAAQ,EAAEqC,KAAK,IAAIpC,UAAU,KAChC,IAAAc,MAAA,CAAAC,aAAA;IACC,eAAc,CAAEhB,QAAQ,EAAEqC,KAAO;IACjCb,SAAS,EAAG,IAAAC,mBAAU,EACrB,8CAA8C,EAC9C;MACC,gBAAgB,EAAE,CAAEzB,QAAQ,EAAEqC;IAC/B,CACD;EAAG,GAEDrC,QAAQ,EAAEqC,KAAK,IAChB,IAAAtB,MAAA,CAAAC,aAAA;IAAKC,GAAG,EAAGjB,QAAQ,EAAEqC,KAAO;IAACnB,GAAG,EAAC;EAAE,CAAE,CAElC,CACL,EAEC,CAAElB,QAAQ,EAAEsC,WAAW,IAAIrC,UAAU,KACtC,IAAAc,MAAA,CAAAC,aAAA;IACC,eAAc,CAAEhB,QAAQ,EAAEsC,WAAa;IACvCd,SAAS,EAAG,IAAAC,mBAAU,EACrB,oDAAoD,EACpD;MACC,gBAAgB,EAAE,CAAEzB,QAAQ,EAAEsC;IAC/B,CACD;EAAG,GAEDtC,QAAQ,EAAEsC,WAAW,IACtB,IAAAvB,MAAA,CAAAC,aAAA,EAAC/B,WAAA,CAAAsD,kBAAI;IAACC,QAAQ;IAACC,aAAa,EAAC;EAAG,GAC7BzC,QAAQ,CAACsC,WACN,CAEH,CAEF,CACL,EAECzC,kBAAkB,IAAIA,kBAAkB,CAAC,CACvC,CAAC;AAER"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_components","_url","_icons","_dom","_viewerSlot","_useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","additionalControls","showRichPreviews","url","richData","isFetching","useRichUrlData","hasRichData","Object","keys","length","displayURL","filterURLForDisplay","safeDecodeURI","isEmptyURL","displayTitle","stripHTML","title","icon","_react","createElement","src","alt","Icon","info","size","globe","__","className","classnames","Fragment","Tooltip","text","placement","ExternalLink","href","Button","edit","label","onClick","iconSize","linkOff","ViewerSlot","fillProps","image","description","__experimentalText","truncate","numberOfLines"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalText as Text,\n\tTooltip,\n} from '@wordpress/components';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n\tadditionalControls,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\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\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\t\t\ttext={ value.url }\n\t\t\t\t\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t</Tooltip>\n\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t{ displayURL }\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) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\n\t\t\t{ !! (\n\t\t\t\t( hasRichData &&\n\t\t\t\t\t( richData?.image || richData?.description ) ) ||\n\t\t\t\tisFetching\n\t\t\t) && (\n\t\t\t\t<div className=\"block-editor-link-control__search-item-bottom\">\n\t\t\t\t\t{ ( richData?.image || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.image }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-image',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.image,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.image && (\n\t\t\t\t\t\t\t\t<img src={ richData?.image } alt=\"\" />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ( richData?.description || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.description }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-description',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.description,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.description && (\n\t\t\t\t\t\t\t\t<Text truncate numberOfLines=\"2\">\n\t\t\t\t\t\t\t\t\t{ richData.description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ additionalControls && additionalControls() }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AAEA,IAAAO,eAAA,GAAAR,sBAAA,CAAAC,OAAA;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAKe,SAASQ,WAAWA,CAAE;EACpCC,KAAK;EACLC,WAAW;EACXC,eAAe,GAAG,KAAK;EACvBC,gBAAgB,GAAG,KAAK;EACxBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH;EACA,MAAMC,gBAAgB,GAAGJ,eAAe,GAAGF,KAAK,EAAEO,GAAG,GAAG,IAAI;EAE5D,MAAM;IAAEC,QAAQ;IAAEC;EAAW,CAAC,GAAG,IAAAC,uBAAc,EAAEJ,gBAAiB,CAAC;;EAEnE;EACA,MAAMK,WAAW,GAAGH,QAAQ,IAAII,MAAM,CAACC,IAAI,CAAEL,QAAS,CAAC,CAACM,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