@wordpress/block-editor 15.14.0 → 15.14.1-next.v.202603102151.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-tools/index.cjs +4 -3
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/iframe/index.cjs +14 -6
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/observe-typing/index.cjs +9 -13
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +22 -6
- package/build/components/provider/index.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +52 -31
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +7 -73
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/private-apis.cjs +1 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -0
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/selectors.cjs +9 -7
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +4 -3
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs +14 -6
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/observe-typing/index.mjs +9 -13
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +22 -6
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +53 -32
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +7 -73
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/private-apis.mjs +3 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -0
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/selectors.mjs +9 -7
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +8 -5
- package/build-style/style.css +8 -5
- package/package.json +39 -39
- package/src/components/block-tools/index.js +11 -4
- package/src/components/iframe/index.js +19 -6
- package/src/components/observe-typing/index.js +10 -14
- package/src/components/provider/index.js +47 -5
- package/src/components/responsive-block-control/style.scss +1 -0
- package/src/hooks/block-fields/index.js +44 -19
- package/src/hooks/block-fields/styles.scss +7 -9
- package/src/hooks/cross-origin-isolation.js +8 -107
- package/src/hooks/test/cross-origin-isolation.js +11 -42
- package/src/private-apis.js +2 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/selectors.js +27 -9
- package/src/store/test/selectors.js +540 -0
|
@@ -95,7 +95,8 @@ function BlockTools({
|
|
|
95
95
|
getBlockEditingMode,
|
|
96
96
|
getBlockName,
|
|
97
97
|
isGroupable,
|
|
98
|
-
getEditedContentOnlySection
|
|
98
|
+
getEditedContentOnlySection,
|
|
99
|
+
canEditBlock
|
|
99
100
|
} = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store));
|
|
100
101
|
const { getGroupingBlockName } = (0, import_data.useSelect)(import_blocks.store);
|
|
101
102
|
const { showEmptyBlockSideInserter, showBlockToolbarPopover } = (0, import_use_show_block_tools.useShowBlockTools)();
|
|
@@ -210,7 +211,7 @@ function BlockTools({
|
|
|
210
211
|
const clientIds = getSelectedBlockClientIds();
|
|
211
212
|
if (clientIds.length === 1) {
|
|
212
213
|
const isContentOnly = getBlockEditingMode(clientIds[0]) === "contentOnly";
|
|
213
|
-
const canRenameBlock = canRename && !isContentOnly;
|
|
214
|
+
const canRenameBlock = canRename && !isContentOnly && canEditBlock(clientIds[0]);
|
|
214
215
|
if (canRenameBlock) {
|
|
215
216
|
event.preventDefault();
|
|
216
217
|
setRenamingBlockClientId(clientIds[0]);
|
|
@@ -228,7 +229,7 @@ function BlockTools({
|
|
|
228
229
|
return;
|
|
229
230
|
}
|
|
230
231
|
if (clientIds.some(
|
|
231
|
-
(id) => getBlockEditingMode(id) !== "default"
|
|
232
|
+
(id) => getBlockEditingMode(id) !== "default" || !canEditBlock(id)
|
|
232
233
|
)) {
|
|
233
234
|
return;
|
|
234
235
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-tools/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { BlockRenameModal, useBlockRename } from '../block-rename';\nimport { BlockVisibilityModal } from '../block-visibility';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t\tgetViewportModalClientIds,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t\tviewportModalClientIds: getViewportModalClientIds(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst {\n\t\tclientId,\n\t\thasFixedToolbar,\n\t\tisTyping,\n\t\tisZoomOutMode,\n\t\tisDragging,\n\t\tviewportModalClientIds,\n\t} = useSelect( selector, [] );\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tgetBlockEditingMode,\n\t\tgetBlockName,\n\t\tisGroupable,\n\t\tgetEditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\tconst [ renamingBlockClientId, setRenamingBlockClientId ] =\n\t\tuseState( null );\n\n\tconst { canRename } = useBlockRename(\n\t\tgetBlockName( getSelectedBlockClientIds()[ 0 ] )\n\t);\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tstopEditingContentOnlySection,\n\t\tshowViewportModal,\n\t\thideViewportModal,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/rename', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length === 1 ) {\n\t\t\t\tconst isContentOnly =\n\t\t\t\t\tgetBlockEditingMode( clientIds[ 0 ] ) === 'contentOnly';\n\t\t\t\tconst canRenameBlock = canRename && ! isContentOnly;\n\t\t\t\tif ( canRenameBlock ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tsetRenamingBlockClientId( clientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst supportsBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't allow visibility toggle for blocks that\n\t\t\t\t// are not in the default editing mode.\n\t\t\t\tif (\n\t\t\t\t\tclientIds.some(\n\t\t\t\t\t\t( id ) => getBlockEditingMode( id ) !== 'default'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Open the visibility breakpoints modal.\n\t\t\t\tshowViewportModal( clientIds );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t\t{ renamingBlockClientId && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tclientId={ renamingBlockClientId }\n\t\t\t\t\tonClose={ () => setRenamingBlockClientId( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ viewportModalClientIds && (\n\t\t\t\t<BlockVisibilityModal\n\t\t\t\t\tclientIds={ viewportModalClientIds }\n\t\t\t\t\tonClose={ hideViewportModal }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAiC;AACjC,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,8BAA2B;AAC3B,0BAAiD;AACjD,8BAAqC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { BlockRenameModal, useBlockRename } from '../block-rename';\nimport { BlockVisibilityModal } from '../block-visibility';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t\tgetViewportModalClientIds,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t\tviewportModalClientIds: getViewportModalClientIds(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst {\n\t\tclientId,\n\t\thasFixedToolbar,\n\t\tisTyping,\n\t\tisZoomOutMode,\n\t\tisDragging,\n\t\tviewportModalClientIds,\n\t} = useSelect( selector, [] );\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tgetBlockEditingMode,\n\t\tgetBlockName,\n\t\tisGroupable,\n\t\tgetEditedContentOnlySection,\n\t\tcanEditBlock,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\tconst [ renamingBlockClientId, setRenamingBlockClientId ] =\n\t\tuseState( null );\n\n\tconst { canRename } = useBlockRename(\n\t\tgetBlockName( getSelectedBlockClientIds()[ 0 ] )\n\t);\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tstopEditingContentOnlySection,\n\t\tshowViewportModal,\n\t\thideViewportModal,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/rename', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length === 1 ) {\n\t\t\t\tconst isContentOnly =\n\t\t\t\t\tgetBlockEditingMode( clientIds[ 0 ] ) === 'contentOnly';\n\t\t\t\tconst canRenameBlock =\n\t\t\t\t\tcanRename &&\n\t\t\t\t\t! isContentOnly &&\n\t\t\t\t\tcanEditBlock( clientIds[ 0 ] );\n\t\t\t\tif ( canRenameBlock ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tsetRenamingBlockClientId( clientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst supportsBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't allow visibility toggle for blocks that are not in the\n\t\t\t\t// default editing mode or when block editing is disabled\n\t\t\t\t// (e.g. Revisions UI with isPreviewMode).\n\t\t\t\tif (\n\t\t\t\t\tclientIds.some(\n\t\t\t\t\t\t( id ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( id ) !== 'default' ||\n\t\t\t\t\t\t\t! canEditBlock( id )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Open the visibility breakpoints modal.\n\t\t\t\tshowViewportModal( clientIds );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t\t{ renamingBlockClientId && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tclientId={ renamingBlockClientId }\n\t\t\t\t\tonClose={ () => setRenamingBlockClientId( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ viewportModalClientIds && (\n\t\t\t\t<BlockVisibilityModal\n\t\t\t\t\tclientIds={ viewportModalClientIds }\n\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yC;AAAA,QAC1C,CAAE;AAAA,QAEF;AAAA,uDAAC,6CAAsB,UAAtB,EAA+B,WAAQ,uBAAQ,KAAM,GACnD;AAAA,aAAE,YAAY,CAAE,iBACjB;AAAA,cAAC,uBAAAC;AAAA,cAAA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,YAGC,8BACD;AAAA,cAAC,4BAAAC;AAAA,cAAA;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,YAGC,2BACD;AAAA,cAAC,6BAAAC;AAAA,cAAA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,YAIC,CAAE,iBAAiB,CAAE,mBACtB;AAAA,cAAC,0BAAQ;AAAA,cAAR;AAAA,gBACA,MAAK;AAAA,gBACL,KAAM;AAAA;AAAA,YACP;AAAA,YAEC;AAAA,YAEF;AAAA,cAAC,0BAAQ;AAAA,cAAR;AAAA,gBACA,MAAK;AAAA,gBACL,KAAM;AAAA;AAAA,YACP;AAAA,YACE,iBAAiB,CAAE,cACpB;AAAA,cAAC,+BAAAC;AAAA,cAAA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,aAEF;AAAA,UACE,yBACD;AAAA,YAAC;AAAA;AAAA,cACA,UAAW;AAAA,cACX,SAAU,MAAM,yBAA0B,IAAK;AAAA;AAAA,UAChD;AAAA,UAEC,0BACD;AAAA,YAAC;AAAA;AAAA,cACA,WAAY;AAAA,cACZ,SAAU;AAAA;AAAA,UACX;AAAA;AAAA;AAAA,IAEF;AAAA;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "useShortcutEventMatch", "blocksStore", "usePasteStyles", "usePopoverScroll", "clsx", "InsertionPoint", "EmptyBlockInserter", "BlockToolbarPopover", "ZoomOutModeInserters"]
|
|
7
7
|
}
|
|
@@ -104,7 +104,6 @@ function getIframeSrc(resolvedAssets) {
|
|
|
104
104
|
<head>
|
|
105
105
|
<meta charset="utf-8">
|
|
106
106
|
<base href="${window.location.href}">
|
|
107
|
-
<script>window.frameElement._load()</script>
|
|
108
107
|
<style>
|
|
109
108
|
html{
|
|
110
109
|
height: auto !important;
|
|
@@ -152,9 +151,6 @@ function Iframe({
|
|
|
152
151
|
const [bodyClasses, setBodyClasses] = (0, import_element.useState)([]);
|
|
153
152
|
const [before, writingFlowRef, after] = (0, import_writing_flow.useWritingFlow)();
|
|
154
153
|
const setRef = (0, import_compose.useRefEffect)((node) => {
|
|
155
|
-
node._load = () => {
|
|
156
|
-
setIframeDocument(node.contentDocument);
|
|
157
|
-
};
|
|
158
154
|
let iFrameDocument;
|
|
159
155
|
function preventFileDropDefault(event) {
|
|
160
156
|
event.preventDefault();
|
|
@@ -175,6 +171,7 @@ function Iframe({
|
|
|
175
171
|
const { contentDocument } = node;
|
|
176
172
|
const { documentElement } = contentDocument;
|
|
177
173
|
iFrameDocument = contentDocument;
|
|
174
|
+
setIframeDocument(contentDocument);
|
|
178
175
|
documentElement.classList.add("block-editor-iframe__html");
|
|
179
176
|
contentDocument.dir = ownerDocument.dir;
|
|
180
177
|
for (const compatStyle of (0, import_get_compatibility_styles.getCompatibilityStyles)()) {
|
|
@@ -205,7 +202,7 @@ function Iframe({
|
|
|
205
202
|
}
|
|
206
203
|
node.addEventListener("load", onLoad);
|
|
207
204
|
return () => {
|
|
208
|
-
|
|
205
|
+
setIframeDocument(void 0);
|
|
209
206
|
node.removeEventListener("load", onLoad);
|
|
210
207
|
iFrameDocument?.removeEventListener(
|
|
211
208
|
"dragover",
|
|
@@ -230,12 +227,23 @@ function Iframe({
|
|
|
230
227
|
iframeDocument
|
|
231
228
|
});
|
|
232
229
|
const disabledRef = (0, import_compose.useDisabled)({ isDisabled: !readonly });
|
|
233
|
-
const
|
|
230
|
+
const unguardedBodyRef = (0, import_compose.useMergeRefs)([
|
|
234
231
|
useBubbleEvents(iframeDocument),
|
|
235
232
|
contentRef,
|
|
236
233
|
writingFlowRef,
|
|
237
234
|
disabledRef
|
|
238
235
|
]);
|
|
236
|
+
const bodyRef = (0, import_compose.useRefEffect)(
|
|
237
|
+
(node) => {
|
|
238
|
+
if (node.ownerDocument.defaultView) {
|
|
239
|
+
unguardedBodyRef(node);
|
|
240
|
+
return () => unguardedBodyRef(null);
|
|
241
|
+
}
|
|
242
|
+
return () => {
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
[unguardedBodyRef]
|
|
246
|
+
);
|
|
239
247
|
const src = getIframeSrc(resolvedAssets);
|
|
240
248
|
const shouldRenderFocusCaptureElements = tabIndex >= 0 && !isPreviewMode;
|
|
241
249
|
const iframe = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/iframe/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, createPortal, forwardRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n\tuseViewportMatch,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { useScaleCanvas } from './use-scale-canvas';\nimport { store as blockEditorStore } from '../../store';\n\nconst ViewportWidthProvider = useViewportMatch.__experimentalWidthProvider;\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( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\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\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nconst iframeSrcCache = new WeakMap();\nconst iframeSrcCleanup = globalThis.FinalizationRegistry\n\t? new globalThis.FinalizationRegistry( ( url ) =>\n\t\t\tURL.revokeObjectURL( url )\n\t )\n\t: undefined;\n\nfunction getIframeSrc( resolvedAssets ) {\n\tlet src = iframeSrcCache.get( resolvedAssets );\n\tif ( src ) {\n\t\treturn src;\n\t}\n\n\t// Correct doctype is required to enable rendering in standards mode.\n\t// Also preload the styles to avoid a flash of unstyled content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<base href=\"${ window.location.href }\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ resolvedAssets.styles ?? '' }\n\t\t${ resolvedAssets.scripts ?? '' }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tsrc = URL.createObjectURL( new Blob( [ html ], { type: 'text/html' } ) );\n\tiframeSrcCache.set( resolvedAssets, src );\n\tiframeSrcCleanup?.register( resolvedAssets, src );\n\treturn src;\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\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.isPreviewMode,\n\t\t};\n\t}, [] );\n\t/** @type {[Document, React.Dispatch<Document>]} */\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\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\t// Prevent clicks on link fragments from navigating away. Note that links\n\t\t// inside `contenteditable` are already disabled by the browser, so\n\t\t// this is for links in blocks outside of `contenteditable`.\n\t\tfunction interceptLinkClicks( event ) {\n\t\t\tif (\n\t\t\t\tevent.target.tagName === 'A' &&\n\t\t\t\tevent.target.getAttribute( 'href' )?.startsWith( '#' )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Manually handle link fragment navigation within the iframe. The iframe's\n\t\t\t\t// location is a blob URL, which can't be used to resolve relative links like\n\t\t\t\t// `#hash`. The relative link would be resolved against the iframe's base URL\n\t\t\t\t// or the parent frame's URL, causing the iframe to navigate to a completely\n\t\t\t\t// different page. Setting the `location.hash` works because it really sets the\n\t\t\t\t// blob URL's hash.\n\t\t\t\t//\n\t\t\t\t// Links with fragments are used for example with footnotes. Clicking on these\n\t\t\t\t// links will scroll smoothly to the anchors in the editor canvas.\n\t\t\t\tiFrameDocument.defaultView.location.hash = event.target\n\t\t\t\t\t.getAttribute( 'href' )\n\t\t\t\t\t.slice( 1 );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\n\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t// the server in the future (which will run the PHP filters).\n\t\tsetBodyClasses(\n\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t( name ) =>\n\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t)\n\t\t);\n\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\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\tiFrameDocument.addEventListener( 'click', interceptLinkClicks );\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\tiFrameDocument?.removeEventListener( 'click', interceptLinkClicks );\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tcontentResizeListener,\n\t\tcontainerResizeListener,\n\t\tcontainerWidth,\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t} = useScaleCanvas( {\n\t\tscale,\n\t\tframeSize: parseInt( frameSize ),\n\t\tiframeDocument,\n\t} );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\tconst src = getIframeSrc( resolvedAssets );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && 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\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\tborder: 0,\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\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\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = 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<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\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<ViewportWidthProvider value={ containerWidth }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</ViewportWidthProvider>\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{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\">\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ scaleContainerWidth }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\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;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAmD;AACnD,kBAAmB;AACnB,qBAKO;AACP,wBAA6D;AAC7D,kBAA0B;AAK1B,0BAA+B;AAC/B,sCAAuC;AACvC,8BAA+B;AAC/B,mBAA0C;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, createPortal, forwardRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n\tuseViewportMatch,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { useScaleCanvas } from './use-scale-canvas';\nimport { store as blockEditorStore } from '../../store';\n\nconst ViewportWidthProvider = useViewportMatch.__experimentalWidthProvider;\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( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\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\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nconst iframeSrcCache = new WeakMap();\nconst iframeSrcCleanup = globalThis.FinalizationRegistry\n\t? new globalThis.FinalizationRegistry( ( url ) =>\n\t\t\tURL.revokeObjectURL( url )\n\t )\n\t: undefined;\n\nfunction getIframeSrc( resolvedAssets ) {\n\tlet src = iframeSrcCache.get( resolvedAssets );\n\tif ( src ) {\n\t\treturn src;\n\t}\n\n\t// Correct doctype is required to enable rendering in standards mode.\n\t// Also preload the styles to avoid a flash of unstyled content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<base href=\"${ window.location.href }\">\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ resolvedAssets.styles ?? '' }\n\t\t${ resolvedAssets.scripts ?? '' }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tsrc = URL.createObjectURL( new Blob( [ html ], { type: 'text/html' } ) );\n\tiframeSrcCache.set( resolvedAssets, src );\n\tiframeSrcCleanup?.register( resolvedAssets, src );\n\treturn src;\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\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.isPreviewMode,\n\t\t};\n\t}, [] );\n\t/** @type {[Document, React.Dispatch<Document>]} */\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\n\tconst setRef = useRefEffect( ( node ) => {\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\t// Prevent clicks on link fragments from navigating away. Note that links\n\t\t// inside `contenteditable` are already disabled by the browser, so\n\t\t// this is for links in blocks outside of `contenteditable`.\n\t\tfunction interceptLinkClicks( event ) {\n\t\t\tif (\n\t\t\t\tevent.target.tagName === 'A' &&\n\t\t\t\tevent.target.getAttribute( 'href' )?.startsWith( '#' )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Manually handle link fragment navigation within the iframe. The iframe's\n\t\t\t\t// location is a blob URL, which can't be used to resolve relative links like\n\t\t\t\t// `#hash`. The relative link would be resolved against the iframe's base URL\n\t\t\t\t// or the parent frame's URL, causing the iframe to navigate to a completely\n\t\t\t\t// different page. Setting the `location.hash` works because it really sets the\n\t\t\t\t// blob URL's hash.\n\t\t\t\t//\n\t\t\t\t// Links with fragments are used for example with footnotes. Clicking on these\n\t\t\t\t// links will scroll smoothly to the anchors in the editor canvas.\n\t\t\t\tiFrameDocument.defaultView.location.hash = event.target\n\t\t\t\t\t.getAttribute( 'href' )\n\t\t\t\t\t.slice( 1 );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\n\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t// the server in the future (which will run the PHP filters).\n\t\tsetBodyClasses(\n\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t( name ) =>\n\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t)\n\t\t);\n\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\t\t\tsetIframeDocument( contentDocument );\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\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\tiFrameDocument.addEventListener( 'click', interceptLinkClicks );\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tsetIframeDocument( undefined );\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\tiFrameDocument?.removeEventListener( 'click', interceptLinkClicks );\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tcontentResizeListener,\n\t\tcontainerResizeListener,\n\t\tcontainerWidth,\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t} = useScaleCanvas( {\n\t\tscale,\n\t\tframeSize: parseInt( frameSize ),\n\t\tiframeDocument,\n\t} );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\n\tconst unguardedBodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Attach the body ref only when the iframe document and window are available.\n\t// When an iframe element is moved in the DOM, like when reordering a list,\n\t// its `window` object is destroyed and recreated, and the `defaultView` field is\n\t// briefly `null`. We need to guard for such calls of the ref callbacks.\n\tconst bodyRef = useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( node.ownerDocument.defaultView ) {\n\t\t\t\tunguardedBodyRef( node );\n\t\t\t\treturn () => unguardedBodyRef( null );\n\t\t\t}\n\t\t\treturn () => {};\n\t\t},\n\t\t[ unguardedBodyRef ]\n\t);\n\n\tconst src = getIframeSrc( resolvedAssets );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && 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\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\tborder: 0,\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\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\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = 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<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\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<ViewportWidthProvider value={ containerWidth }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</ViewportWidthProvider>\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{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\">\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ scaleContainerWidth }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\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;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAmD;AACnD,kBAAmB;AACnB,qBAKO;AACP,wBAA6D;AAC7D,kBAA0B;AAK1B,0BAA+B;AAC/B,sCAAuC;AACvC,8BAA+B;AAC/B,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AM,YAAY,kBAAkB;AACpC;AAAA,cACC;AAAA,cACA,OAAO;AAAA,cACP,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,QAEE,gCACD;AAAA,UACC;AAAA,YAAC;AAAA;AAAA,cACA,KAAM;AAAA,cACN,eAAY,YAAAC;AAAA,gBACX;AAAA,gBACA;AAAA,gBACA,GAAG;AAAA,cACJ;AAAA,cAEE;AAAA;AAAA,gBACF,4CAAC,kBAAAC,6BAAA,EAAc,UAAW,gBACzB,sDAAC,yBAAsB,OAAQ,gBAC5B,UACH,GACD;AAAA;AAAA;AAAA,UACD;AAAA,UACA,eAAe;AAAA,QAChB;AAAA;AAAA,IACF;AAAA,IACE,oCAAoC;AAAA,KACvC;AAGD,SACC,6CAAC,SAAI,WAAU,kCACZ;AAAA;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAD;AAAA,UACX;AAAA,UACA,eAAe;AAAA,QAChB;AAAA,QACA,OAAQ;AAAA,UACP,2DACC,eAAe,GAAI,mBAAoB;AAAA,QACzC;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;AAEA,SAAS,cAAe,OAAO,KAAM;AACpC,QAAM,oBAAgB;AAAA,IACrB,CAAE,WACD,OAAQ,aAAAD,KAAiB,EAAE,YAAY,EAAE;AAAA,IAC1C,CAAC;AAAA,EACF;AAOA,MAAK,CAAE,eAAgB;AACtB,WAAO;AAAA,EACR;AAEA,SAAO,4CAAC,UAAS,GAAG,OAAQ,cAAe,KAAM;AAClD;AAEA,IAAO,qBAAQ,2BAAY,aAAc;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx", "StyleProvider"]
|
|
7
7
|
}
|
|
@@ -80,23 +80,18 @@ function useMouseMoveTypingReset() {
|
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
function useTypingObserver() {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
}, []);
|
|
83
|
+
const isTyping = (0, import_data.useSelect)(
|
|
84
|
+
(select) => select(import_store.store).isTyping(),
|
|
85
|
+
[]
|
|
86
|
+
);
|
|
89
87
|
const { startTyping, stopTyping } = (0, import_data.useDispatch)(import_store.store);
|
|
90
88
|
const ref1 = useMouseMoveTypingReset();
|
|
91
89
|
const ref2 = (0, import_compose.useRefEffect)(
|
|
92
90
|
(node) => {
|
|
93
|
-
const { ownerDocument } = node;
|
|
94
|
-
const { defaultView } = ownerDocument;
|
|
95
|
-
const selection = defaultView.getSelection();
|
|
96
91
|
if (isTyping) {
|
|
97
92
|
let stopTypingOnNonTextField2 = function(event) {
|
|
98
93
|
const { target } = event;
|
|
99
|
-
timerId = defaultView.setTimeout(() => {
|
|
94
|
+
timerId = node.ownerDocument.defaultView.setTimeout(() => {
|
|
100
95
|
if (!(0, import_dom.isTextField)(target)) {
|
|
101
96
|
stopTyping();
|
|
102
97
|
}
|
|
@@ -107,6 +102,7 @@ function useTypingObserver() {
|
|
|
107
102
|
stopTyping();
|
|
108
103
|
}
|
|
109
104
|
}, stopTypingOnSelectionUncollapse2 = function() {
|
|
105
|
+
const selection = node.ownerDocument.defaultView.getSelection();
|
|
110
106
|
if (!selection.isCollapsed) {
|
|
111
107
|
stopTyping();
|
|
112
108
|
}
|
|
@@ -115,12 +111,12 @@ function useTypingObserver() {
|
|
|
115
111
|
let timerId;
|
|
116
112
|
node.addEventListener("focus", stopTypingOnNonTextField2);
|
|
117
113
|
node.addEventListener("keydown", stopTypingOnEscapeKey2);
|
|
118
|
-
ownerDocument.addEventListener(
|
|
114
|
+
node.ownerDocument.addEventListener(
|
|
119
115
|
"selectionchange",
|
|
120
116
|
stopTypingOnSelectionUncollapse2
|
|
121
117
|
);
|
|
122
118
|
return () => {
|
|
123
|
-
defaultView.clearTimeout(timerId);
|
|
119
|
+
node.ownerDocument.defaultView.clearTimeout(timerId);
|
|
124
120
|
node.removeEventListener(
|
|
125
121
|
"focus",
|
|
126
122
|
stopTypingOnNonTextField2
|
|
@@ -129,7 +125,7 @@ function useTypingObserver() {
|
|
|
129
125
|
"keydown",
|
|
130
126
|
stopTypingOnEscapeKey2
|
|
131
127
|
);
|
|
132
|
-
ownerDocument.removeEventListener(
|
|
128
|
+
node.ownerDocument.removeEventListener(
|
|
133
129
|
"selectionchange",
|
|
134
130
|
stopTypingOnSelectionUncollapse2
|
|
135
131
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/observe-typing/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport {\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n\tESCAPE,\n\tTAB,\n} from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Set of key codes upon which typing is to be initiated on a keydown event.\n *\n * @type {Set<number>}\n */\nconst KEY_DOWN_ELIGIBLE_KEY_CODES = new Set( [\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n] );\n\n/**\n * Returns true if a given keydown event can be inferred as intent to start\n * typing, or false otherwise. A keydown is considered eligible if it is a\n * text navigation without shift active.\n *\n * @param {KeyboardEvent} event Keydown event to test.\n *\n * @return {boolean} Whether event is eligible to start typing.\n */\nfunction isKeyDownEligibleForStartTyping( event ) {\n\tconst { keyCode, shiftKey } = event;\n\treturn ! shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has( keyCode );\n}\n\n/**\n * Removes the `isTyping` flag when the mouse moves in the document of the given\n * element.\n */\nexport function useMouseMoveTypingReset() {\n\tconst isTyping = useSelect(\n\t\t( select ) => select( blockEditorStore ).isTyping(),\n\t\t[]\n\t);\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isTyping ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tlet lastClientX;\n\t\t\tlet lastClientY;\n\n\t\t\t/**\n\t\t\t * On mouse move, unset typing flag if user has moved cursor.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Mousemove event.\n\t\t\t */\n\t\t\tfunction stopTypingOnMouseMove( event ) {\n\t\t\t\tconst { clientX, clientY } = event;\n\n\t\t\t\t// We need to check that the mouse really moved because Safari\n\t\t\t\t// triggers mousemove events when shift or ctrl are pressed.\n\t\t\t\tif (\n\t\t\t\t\tlastClientX &&\n\t\t\t\t\tlastClientY &&\n\t\t\t\t\t( lastClientX !== clientX || lastClientY !== clientY )\n\t\t\t\t) {\n\t\t\t\t\tstopTyping();\n\t\t\t\t}\n\n\t\t\t\tlastClientX = clientX;\n\t\t\t\tlastClientY = clientY;\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'mousemove',\n\t\t\t\tstopTypingOnMouseMove\n\t\t\t);\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousemove',\n\t\t\t\t\tstopTypingOnMouseMove\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t[ isTyping, stopTyping ]\n\t);\n}\n\n/**\n * Sets and removes the `isTyping` flag based on user actions:\n *\n * - Sets the flag if the user types within the given element.\n * - Removes the flag when the user selects some text, focuses a non-text\n * field, presses ESC or TAB, or moves the mouse in the document.\n */\nexport function useTypingObserver() {\n\tconst
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2C;AAC3C,kBAAuC;AACvC,iBAA4B;AAC5B,sBASO;AAKP,mBAA0C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport {\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n\tESCAPE,\n\tTAB,\n} from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Set of key codes upon which typing is to be initiated on a keydown event.\n *\n * @type {Set<number>}\n */\nconst KEY_DOWN_ELIGIBLE_KEY_CODES = new Set( [\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n] );\n\n/**\n * Returns true if a given keydown event can be inferred as intent to start\n * typing, or false otherwise. A keydown is considered eligible if it is a\n * text navigation without shift active.\n *\n * @param {KeyboardEvent} event Keydown event to test.\n *\n * @return {boolean} Whether event is eligible to start typing.\n */\nfunction isKeyDownEligibleForStartTyping( event ) {\n\tconst { keyCode, shiftKey } = event;\n\treturn ! shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has( keyCode );\n}\n\n/**\n * Removes the `isTyping` flag when the mouse moves in the document of the given\n * element.\n */\nexport function useMouseMoveTypingReset() {\n\tconst isTyping = useSelect(\n\t\t( select ) => select( blockEditorStore ).isTyping(),\n\t\t[]\n\t);\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isTyping ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tlet lastClientX;\n\t\t\tlet lastClientY;\n\n\t\t\t/**\n\t\t\t * On mouse move, unset typing flag if user has moved cursor.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Mousemove event.\n\t\t\t */\n\t\t\tfunction stopTypingOnMouseMove( event ) {\n\t\t\t\tconst { clientX, clientY } = event;\n\n\t\t\t\t// We need to check that the mouse really moved because Safari\n\t\t\t\t// triggers mousemove events when shift or ctrl are pressed.\n\t\t\t\tif (\n\t\t\t\t\tlastClientX &&\n\t\t\t\t\tlastClientY &&\n\t\t\t\t\t( lastClientX !== clientX || lastClientY !== clientY )\n\t\t\t\t) {\n\t\t\t\t\tstopTyping();\n\t\t\t\t}\n\n\t\t\t\tlastClientX = clientX;\n\t\t\t\tlastClientY = clientY;\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'mousemove',\n\t\t\t\tstopTypingOnMouseMove\n\t\t\t);\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousemove',\n\t\t\t\t\tstopTypingOnMouseMove\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t[ isTyping, stopTyping ]\n\t);\n}\n\n/**\n * Sets and removes the `isTyping` flag based on user actions:\n *\n * - Sets the flag if the user types within the given element.\n * - Removes the flag when the user selects some text, focuses a non-text\n * field, presses ESC or TAB, or moves the mouse in the document.\n */\nexport function useTypingObserver() {\n\tconst isTyping = useSelect(\n\t\t( select ) => select( blockEditorStore ).isTyping(),\n\t\t[]\n\t);\n\tconst { startTyping, stopTyping } = useDispatch( blockEditorStore );\n\n\tconst ref1 = useMouseMoveTypingReset();\n\tconst ref2 = useRefEffect(\n\t\t( node ) => {\n\t\t\t// Listeners to stop typing should only be added when typing.\n\t\t\t// Listeners to start typing should only be added when not typing.\n\t\t\tif ( isTyping ) {\n\t\t\t\tlet timerId;\n\n\t\t\t\t/**\n\t\t\t\t * Stops typing when focus transitions to a non-text field element.\n\t\t\t\t *\n\t\t\t\t * @param {FocusEvent} event Focus event.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnNonTextField( event ) {\n\t\t\t\t\tconst { target } = event;\n\n\t\t\t\t\t// Since focus to a non-text field via arrow key will trigger\n\t\t\t\t\t// before the keydown event, wait until after current stack\n\t\t\t\t\t// before evaluating whether typing is to be stopped. Otherwise,\n\t\t\t\t\t// typing will re-start.\n\t\t\t\t\ttimerId = node.ownerDocument.defaultView.setTimeout( () => {\n\t\t\t\t\t\tif ( ! isTextField( target ) ) {\n\t\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * Unsets typing flag if user presses Escape while typing flag is\n\t\t\t\t * active.\n\t\t\t\t *\n\t\t\t\t * @param {KeyboardEvent} event Keypress or keydown event to\n\t\t\t\t * interpret.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnEscapeKey( event ) {\n\t\t\t\t\tconst { keyCode } = event;\n\n\t\t\t\t\tif ( keyCode === ESCAPE || keyCode === TAB ) {\n\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * On selection change, unset typing flag if user has made an\n\t\t\t\t * uncollapsed (shift) selection.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnSelectionUncollapse() {\n\t\t\t\t\tconst selection =\n\t\t\t\t\t\tnode.ownerDocument.defaultView.getSelection();\n\t\t\t\t\tif ( ! selection.isCollapsed ) {\n\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnode.addEventListener( 'focus', stopTypingOnNonTextField );\n\t\t\t\tnode.addEventListener( 'keydown', stopTypingOnEscapeKey );\n\n\t\t\t\tnode.ownerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tstopTypingOnSelectionUncollapse\n\t\t\t\t);\n\n\t\t\t\treturn () => {\n\t\t\t\t\tnode.ownerDocument.defaultView.clearTimeout( timerId );\n\t\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t\t'focus',\n\t\t\t\t\t\tstopTypingOnNonTextField\n\t\t\t\t\t);\n\t\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t\t'keydown',\n\t\t\t\t\t\tstopTypingOnEscapeKey\n\t\t\t\t\t);\n\t\t\t\t\tnode.ownerDocument.removeEventListener(\n\t\t\t\t\t\t'selectionchange',\n\t\t\t\t\t\tstopTypingOnSelectionUncollapse\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles a keypress or keydown event to infer intention to start\n\t\t\t * typing.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keypress or keydown event to interpret.\n\t\t\t */\n\t\t\tfunction startTypingInTextField( event ) {\n\t\t\t\tconst { type, target } = event;\n\n\t\t\t\t// Abort early if already typing, or key press is incurred outside a\n\t\t\t\t// text field (e.g. arrow-ing through toolbar buttons).\n\t\t\t\t// Ignore typing if outside the current DOM container\n\t\t\t\tif ( ! isTextField( target ) || ! node.contains( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Special-case keydown because certain keys do not emit a keypress\n\t\t\t\t// event. Conversely avoid keydown as the canonical event since\n\t\t\t\t// there are many keydown which are explicitly not targeted for\n\t\t\t\t// typing.\n\t\t\t\tif (\n\t\t\t\t\ttype === 'keydown' &&\n\t\t\t\t\t! isKeyDownEligibleForStartTyping( event )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstartTyping();\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keypress', startTypingInTextField );\n\t\t\tnode.addEventListener( 'keydown', startTypingInTextField );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keypress', startTypingInTextField );\n\t\t\t\tnode.removeEventListener( 'keydown', startTypingInTextField );\n\t\t\t};\n\t\t},\n\t\t[ isTyping, startTyping, stopTyping ]\n\t);\n\n\treturn useMergeRefs( [ ref1, ref2 ] );\n}\n\nfunction ObserveTyping( { children } ) {\n\treturn <div ref={ useTypingObserver() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md\n */\nexport default ObserveTyping;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;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kB,WAAW,sBAAuB;AAEzD,aAAO,MAAM;AACZ,aAAK,oBAAqB,YAAY,sBAAuB;AAC7D,aAAK,oBAAqB,WAAW,sBAAuB;AAAA,MAC7D;AAAA,IACD;AAAA,IACA,CAAE,UAAU,aAAa,UAAW;AAAA,EACrC;AAEA,aAAO,6BAAc,CAAE,MAAM,IAAK,CAAE;AACrC;AAEA,SAAS,cAAe,EAAE,SAAS,GAAI;AACtC,SAAO,4CAAC,SAAI,KAAM,kBAAkB,GAAM,UAAU;AACrD;AAKA,IAAO,yBAAQ;",
|
|
6
6
|
"names": ["blockEditorStore", "stopTypingOnNonTextField", "stopTypingOnEscapeKey", "stopTypingOnSelectionUncollapse"]
|
|
7
7
|
}
|
|
@@ -46,6 +46,7 @@ var import_block_refs_provider = require("./block-refs-provider.cjs");
|
|
|
46
46
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
47
47
|
var import_keyboard_shortcuts = __toESM(require("../keyboard-shortcuts/index.cjs"));
|
|
48
48
|
var import_use_media_upload_settings = __toESM(require("./use-media-upload-settings.cjs"));
|
|
49
|
+
var import_private_keys = require("../../store/private-keys.cjs");
|
|
49
50
|
var import_selection_context = require("./selection-context.cjs");
|
|
50
51
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
52
|
var noop = () => {
|
|
@@ -78,7 +79,7 @@ function shouldEnableClientSideMediaProcessing() {
|
|
|
78
79
|
isClientSideMediaEnabledCache = true;
|
|
79
80
|
return true;
|
|
80
81
|
}
|
|
81
|
-
function mediaUpload(registry, {
|
|
82
|
+
function mediaUpload(registry, settings, {
|
|
82
83
|
allowedTypes,
|
|
83
84
|
additionalData = {},
|
|
84
85
|
filesList,
|
|
@@ -90,7 +91,10 @@ function mediaUpload(registry, {
|
|
|
90
91
|
void registry.dispatch(import_upload_media.store).addItems({
|
|
91
92
|
files: Array.from(filesList),
|
|
92
93
|
onChange: onFileChange,
|
|
93
|
-
onSuccess
|
|
94
|
+
onSuccess: (attachments) => {
|
|
95
|
+
settings?.[import_private_keys.mediaUploadOnSuccessKey]?.(attachments);
|
|
96
|
+
onSuccess?.(attachments);
|
|
97
|
+
},
|
|
94
98
|
onBatchSuccess,
|
|
95
99
|
onError: ({ message }) => onError(message),
|
|
96
100
|
additionalData,
|
|
@@ -110,15 +114,27 @@ var ExperimentalBlockEditorProvider = (0, import_with_registry_provider.default)
|
|
|
110
114
|
} = props;
|
|
111
115
|
const mediaUploadSettings = (0, import_use_media_upload_settings.default)(_settings);
|
|
112
116
|
const isClientSideMediaEnabled = shouldEnableClientSideMediaProcessing();
|
|
117
|
+
const isMediaUploadIntercepted = !!_settings?.mediaUpload?.__isMediaUploadInterceptor;
|
|
113
118
|
const settings = (0, import_element.useMemo)(() => {
|
|
114
|
-
if (isClientSideMediaEnabled && _settings?.mediaUpload) {
|
|
119
|
+
if (isClientSideMediaEnabled && _settings?.mediaUpload && !isMediaUploadIntercepted) {
|
|
120
|
+
const interceptor = mediaUpload.bind(
|
|
121
|
+
null,
|
|
122
|
+
registry,
|
|
123
|
+
_settings
|
|
124
|
+
);
|
|
125
|
+
interceptor.__isMediaUploadInterceptor = true;
|
|
115
126
|
return {
|
|
116
127
|
..._settings,
|
|
117
|
-
mediaUpload:
|
|
128
|
+
mediaUpload: interceptor
|
|
118
129
|
};
|
|
119
130
|
}
|
|
120
131
|
return _settings;
|
|
121
|
-
}, [
|
|
132
|
+
}, [
|
|
133
|
+
_settings,
|
|
134
|
+
registry,
|
|
135
|
+
isClientSideMediaEnabled,
|
|
136
|
+
isMediaUploadIntercepted
|
|
137
|
+
]);
|
|
122
138
|
const { __experimentalUpdateSettings } = (0, import_lock_unlock.unlock)(
|
|
123
139
|
(0, import_data.useDispatch)(import_store.store)
|
|
124
140
|
);
|
|
@@ -165,7 +181,7 @@ var ExperimentalBlockEditorProvider = (0, import_with_registry_provider.default)
|
|
|
165
181
|
),
|
|
166
182
|
children
|
|
167
183
|
] });
|
|
168
|
-
if (isClientSideMediaEnabled) {
|
|
184
|
+
if (isClientSideMediaEnabled && !isMediaUploadIntercepted) {
|
|
169
185
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
170
186
|
import_upload_media.MediaUploadProvider,
|
|
171
187
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/provider/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport {\n\tMediaUploadProvider,\n\tstore as uploadStore,\n\tdetectClientSideMediaSupport,\n} from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport useMediaUploadSettings from './use-media-upload-settings';\nimport { SelectionContext } from './selection-context';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst noop = () => {};\n\n/**\n * Flag to track if we've already logged the fallback message.\n */\nlet hasLoggedFallback = false;\n\n/**\n * Cached result of whether client-side media processing should be enabled.\n * This is computed once per session for efficiency and stability.\n */\nlet isClientSideMediaEnabledCache = null;\n\n/**\n * Checks if client-side media processing should be enabled.\n *\n * Returns true only if:\n * 1. The client-side media processing flag is enabled\n * 2. The browser supports WebAssembly, SharedArrayBuffer, cross-origin isolation, and CSP allows blob workers\n *\n * The result is cached for the session to ensure stability during React renders.\n *\n * @return {boolean} Whether client-side media processing should be enabled.\n */\nfunction shouldEnableClientSideMediaProcessing() {\n\t// Return cached result if available.\n\tif ( isClientSideMediaEnabledCache !== null ) {\n\t\treturn isClientSideMediaEnabledCache;\n\t}\n\n\t// Check if the client-side media processing flag is enabled first.\n\tif ( ! window.__clientSideMediaProcessing ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\t// Safety check in case the import is unavailable.\n\tif ( typeof detectClientSideMediaSupport !== 'function' ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tconst detection = detectClientSideMediaSupport();\n\tif ( ! detection || ! detection.supported ) {\n\t\t// Only log once per session to avoid console spam.\n\t\tif ( ! hasLoggedFallback ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.info(\n\t\t\t\t`Client-side media processing unavailable: ${ detection.reason }. Using server-side processing.`\n\t\t\t);\n\t\t\thasLoggedFallback = true;\n\t\t}\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tisClientSideMediaEnabledCache = true;\n\treturn true;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction mediaUpload(\n\tregistry,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\tfiles: Array.from( filesList ),\n\t\tonChange: onFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t\tonError: ( { message } ) => onError( message ),\n\t\tadditionalData,\n\t\tallowedTypes,\n\t} );\n}\n\n/**\n * Calls useBlockSync as a child of SelectionContext.Provider so that the\n * hook can read selection state from the context provided by this tree\n * rather than from a parent provider (which may not exist for the root).\n *\n * @param {Object} props Props forwarded to useBlockSync.\n */\nfunction BlockSyncEffect( props ) {\n\tuseBlockSync( props );\n\treturn null;\n}\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst {\n\t\t\tsettings: _settings,\n\t\t\tregistry,\n\t\t\tstripExperimentalSettings = false,\n\t\t} = props;\n\n\t\tconst mediaUploadSettings = useMediaUploadSettings( _settings );\n\n\t\tconst isClientSideMediaEnabled =\n\t\t\tshouldEnableClientSideMediaProcessing();\n\n\t\tconst settings = useMemo( () => {\n\t\t\tif (
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAA2C;AAC3C,wBAAiC;AACjC,0BAIO;AAKP,oCAAiC;AACjC,4BAAyB;AACzB,mBAA0C;AAC1C,iCAAkC;AAClC,yBAAuB;AACvB,gCAA8B;AAC9B,uCAAmC;AACnC,+BAAiC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport {\n\tMediaUploadProvider,\n\tstore as uploadStore,\n\tdetectClientSideMediaSupport,\n} from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport useMediaUploadSettings from './use-media-upload-settings';\nimport { mediaUploadOnSuccessKey } from '../../store/private-keys';\nimport { SelectionContext } from './selection-context';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst noop = () => {};\n\n/**\n * Flag to track if we've already logged the fallback message.\n */\nlet hasLoggedFallback = false;\n\n/**\n * Cached result of whether client-side media processing should be enabled.\n * This is computed once per session for efficiency and stability.\n */\nlet isClientSideMediaEnabledCache = null;\n\n/**\n * Checks if client-side media processing should be enabled.\n *\n * Returns true only if:\n * 1. The client-side media processing flag is enabled\n * 2. The browser supports WebAssembly, SharedArrayBuffer, cross-origin isolation, and CSP allows blob workers\n *\n * The result is cached for the session to ensure stability during React renders.\n *\n * @return {boolean} Whether client-side media processing should be enabled.\n */\nfunction shouldEnableClientSideMediaProcessing() {\n\t// Return cached result if available.\n\tif ( isClientSideMediaEnabledCache !== null ) {\n\t\treturn isClientSideMediaEnabledCache;\n\t}\n\n\t// Check if the client-side media processing flag is enabled first.\n\tif ( ! window.__clientSideMediaProcessing ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\t// Safety check in case the import is unavailable.\n\tif ( typeof detectClientSideMediaSupport !== 'function' ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tconst detection = detectClientSideMediaSupport();\n\tif ( ! detection || ! detection.supported ) {\n\t\t// Only log once per session to avoid console spam.\n\t\tif ( ! hasLoggedFallback ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.info(\n\t\t\t\t`Client-side media processing unavailable: ${ detection.reason }. Using server-side processing.`\n\t\t\t);\n\t\t\thasLoggedFallback = true;\n\t\t}\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tisClientSideMediaEnabledCache = true;\n\treturn true;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} settings Block editor settings.\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction mediaUpload(\n\tregistry,\n\tsettings,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\tfiles: Array.from( filesList ),\n\t\tonChange: onFileChange,\n\t\tonSuccess: ( attachments ) => {\n\t\t\tsettings?.[ mediaUploadOnSuccessKey ]?.( attachments );\n\t\t\tonSuccess?.( attachments );\n\t\t},\n\t\tonBatchSuccess,\n\t\tonError: ( { message } ) => onError( message ),\n\t\tadditionalData,\n\t\tallowedTypes,\n\t} );\n}\n\n/**\n * Calls useBlockSync as a child of SelectionContext.Provider so that the\n * hook can read selection state from the context provided by this tree\n * rather than from a parent provider (which may not exist for the root).\n *\n * @param {Object} props Props forwarded to useBlockSync.\n */\nfunction BlockSyncEffect( props ) {\n\tuseBlockSync( props );\n\treturn null;\n}\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst {\n\t\t\tsettings: _settings,\n\t\t\tregistry,\n\t\t\tstripExperimentalSettings = false,\n\t\t} = props;\n\n\t\tconst mediaUploadSettings = useMediaUploadSettings( _settings );\n\n\t\tconst isClientSideMediaEnabled =\n\t\t\tshouldEnableClientSideMediaProcessing();\n\n\t\t// Nested providers (e.g. from useBlockPreview) inherit settings\n\t\t// where mediaUpload has already been replaced with the\n\t\t// interceptor. Detect this so we skip the replacement and\n\t\t// MediaUploadProvider for them \u2014 see the longer comment below.\n\t\tconst isMediaUploadIntercepted =\n\t\t\t!! _settings?.mediaUpload?.__isMediaUploadInterceptor;\n\n\t\tconst settings = useMemo( () => {\n\t\t\tif (\n\t\t\t\tisClientSideMediaEnabled &&\n\t\t\t\t_settings?.mediaUpload &&\n\t\t\t\t! isMediaUploadIntercepted\n\t\t\t) {\n\t\t\t\t// Create a new object so that the original props.settings.mediaUpload is not modified.\n\t\t\t\tconst interceptor = mediaUpload.bind(\n\t\t\t\t\tnull,\n\t\t\t\t\tregistry,\n\t\t\t\t\t_settings\n\t\t\t\t);\n\t\t\t\tinterceptor.__isMediaUploadInterceptor = true;\n\t\t\t\treturn {\n\t\t\t\t\t..._settings,\n\t\t\t\t\tmediaUpload: interceptor,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn _settings;\n\t\t}, [\n\t\t\t_settings,\n\t\t\tregistry,\n\t\t\tisClientSideMediaEnabled,\n\t\t\tisMediaUploadIntercepted,\n\t\t] );\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Store selection and onChangeSelection in refs and expose\n\t\t// stable getters/callers so that the context value is a\n\t\t// complete constant. This prevents re-rendering the entire\n\t\t// block tree (including async-rendered off-screen blocks)\n\t\t// when either value changes.\n\t\tconst selectionRef = useRef( props.selection );\n\t\tselectionRef.current = props.selection;\n\t\tconst onChangeSelectionRef = useRef( props.onChangeSelection ?? noop );\n\t\tonChangeSelectionRef.current = props.onChangeSelection ?? noop;\n\n\t\tconst selectionContextValue = useMemo(\n\t\t\t() => ( {\n\t\t\t\tgetSelection: () => selectionRef.current,\n\t\t\t\tonChangeSelection: ( ...args ) =>\n\t\t\t\t\tonChangeSelectionRef.current( ...args ),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\n\t\tconst children = (\n\t\t\t<SlotFillProvider passthrough>\n\t\t\t\t{ ! settings?.isPreviewMode && <KeyboardShortcuts.Register /> }\n\t\t\t\t<BlockRefsProvider>{ props.children }</BlockRefsProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\n\t\tconst content = (\n\t\t\t<SelectionContext.Provider value={ selectionContextValue }>\n\t\t\t\t<BlockSyncEffect\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tvalue={ props.value }\n\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\tonInput={ props.onInput }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</SelectionContext.Provider>\n\t\t);\n\n\t\t// MediaUploadProvider writes the mediaUpload function from\n\t\t// _settings into the shared upload-media store so the store can\n\t\t// hand files off to the server. useMediaUploadSettings extracts\n\t\t// mediaUpload from the original _settings prop \u2014 *before* the\n\t\t// interceptor replacement above \u2014 so the store receives the\n\t\t// real server-side upload function.\n\t\t//\n\t\t// Only the first (outermost) provider should do this.\n\t\t// Nested providers (e.g. from useBlockPreview in\n\t\t// core/post-template) inherit settings that already contain\n\t\t// the interceptor, so their MediaUploadProvider would\n\t\t// overwrite the store's server-side function with the\n\t\t// interceptor, causing uploads to loop instead of reaching\n\t\t// the server.\n\t\tif ( isClientSideMediaEnabled && ! isMediaUploadIntercepted ) {\n\t\t\treturn (\n\t\t\t\t<MediaUploadProvider\n\t\t\t\t\tsettings={ mediaUploadSettings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t>\n\t\t\t\t\t{ content }\n\t\t\t\t</MediaUploadProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn content;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider { ...props } stripExperimentalSettings>\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