@wordpress/block-editor 10.1.0 → 10.1.1-next.4d3b314fd5.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-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +4 -4
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-popover/index.js +0 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +6 -3
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +1 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +19 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +62 -20
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +14 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/index.js +13 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +76 -23
- package/build/hooks/layout.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +4 -4
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-popover/index.js +0 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +6 -3
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +19 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +62 -21
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +14 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +73 -23
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +21 -1
- package/build-style/style.css +21 -1
- package/package.json +29 -29
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-draggable/test/index.native.js +0 -9
- package/src/components/block-list/use-in-between-inserter.js +5 -5
- package/src/components/block-popover/index.js +0 -1
- package/src/components/block-preview/style.scss +13 -0
- package/src/components/block-tools/index.js +1 -1
- package/src/components/block-tools/use-block-toolbar-popover-props.js +6 -0
- package/src/components/index.js +1 -0
- package/src/components/url-popover/image-url-input-ui.js +1 -1
- package/src/components/use-block-drop-zone/index.js +26 -1
- package/src/components/use-on-block-drop/index.js +110 -35
- package/src/components/use-on-block-drop/test/index.js +33 -43
- package/src/components/writing-flow/use-arrow-nav.js +12 -8
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +64 -21
- package/src/index.js +2 -0
- package/src/store/selectors.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","blockEditorStore","rootClientId","blockName","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","transferData","type","srcClientIds","event","length","onDraggableStart","onDraggableEnd"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","blockEditorStore","rootClientId","blockName","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","event","length","onDraggableStart","onDraggableEnd"],"mappings":";;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,cAAc,GAAG,QAMhB;AAAA,MANkB;AACxBC,IAAAA,QADwB;AAExBC,IAAAA,SAFwB;AAGxBC,IAAAA,cAHwB;AAIxBC,IAAAA,WAJwB;AAKxBC,IAAAA;AALwB,GAMlB;AACN,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,WAAnB;AAAgCC,IAAAA;AAAhC,MAAyC,qBAC5CC,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA,oBAAjB;AAAuCC,MAAAA;AAAvC,QACLH,MAAM,CAAEI,YAAF,CADP;AAEA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,SAAS,CAAE,CAAF,CAAX,CAAzC;AACA,UAAMa,SAAS,GAAGH,YAAY,CAAEV,SAAS,CAAE,CAAF,CAAX,CAA9B;AAEA,WAAO;AACNI,MAAAA,eAAe,EAAEQ,YADX;AAENP,MAAAA,WAAW,EAAEG,aAAa,CAAER,SAAF,EAAaY,YAAb,CAFpB;AAGNN,MAAAA,IAAI,mBAAE,0BAAcO,SAAd,CAAF,kDAAE,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AA2B,EAC1B,4BAAC,sBAAD;AAAoB,MAAA,KAAK,EAAGH,SAAS,CAAC0B,MAAtC;AAA+C,MAAA,IAAI,EAAGpB;AAAtD;AA1BF,KA6BG,SAA4C;AAAA,QAA1C;AAAEqB,MAAAA,gBAAF;AAAoBC,MAAAA;AAApB,KAA0C;AAC7C,WAAO7B,QAAQ,CAAE;AAChBsB,MAAAA,SAAS,EAAE,IADK;AAEhBnB,MAAAA,WAAW,EAAEyB,gBAFG;AAGhBxB,MAAAA,SAAS,EAAEyB;AAHK,KAAF,CAAf;AAKA,GAnCF,CADD;AAuCA,CAvFD;;eAyFe9B,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n} ) => {\n\tconst { srcRootClientId, isDraggable, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canMoveBlocks, getBlockRootClientId, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: getBlockType( blockName )?.icon,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\tisDragging.current = true;\n\n\t\t\t\tstartScrolling( event );\n\n\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\tonDragStart();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip count={ clientIds.length } icon={ icon } />\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"]}
|
|
@@ -81,12 +81,12 @@ function useInBetweenInserter() {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const offsetLeft = event.clientX - rect.left;
|
|
84
|
+
const offsetTop = event.clientY;
|
|
85
|
+
const offsetLeft = event.clientX;
|
|
87
86
|
const children = Array.from(event.target.children);
|
|
88
87
|
let element = children.find(blockEl => {
|
|
89
|
-
|
|
88
|
+
const blockElRect = blockEl.getBoundingClientRect();
|
|
89
|
+
return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockElRect.top > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockElRect.left > offsetLeft;
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
if (!element) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"names":["useInBetweenInserter","openRef","InsertionPointOpenRef","isInBetweenInserterDisabled","select","blockEditorStore","getSettings","hasReducedUI","__unstableGetEditorMode","getBlockListSettings","getBlockRootClientId","getBlockIndex","isBlockInsertionPointVisible","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","showInsertionPoint","hideInsertionPoint","delayedShowInsertionPoint","trailing","node","onMouseMove","event","current","target","classList","contains","cancel","rootClientId","blockElement","getAttribute","closest","orientation","rect","getBoundingClientRect","offsetTop","clientY","top","offsetLeft","clientX","left","children","Array","from","element","find","blockEl","id","firstElementChild","clientId","slice","length","includes","elementRect","bottom","right","index","__unstableWithInserter","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIO,SAASA,oBAAT,GAAgC;AACtC,QAAMC,OAAO,GAAG,yBAAYC,qCAAZ,CAAhB;AACA,QAAMC,2BAA2B,GAAG,qBACjCC,MAAF,IACCA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,GAAyCC,YAAzC,IACAH,MAAM,CAAEC,YAA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useRefEffect, useDebounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().hasReducedUI ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tisBlockInsertionPointVisible,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t} = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst delayedShowInsertionPoint = useDebounce( showInsertionPoint, 500, {\n\t\ttrailing: true,\n\t} );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\tif ( openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\t// Don't set the insertion point if the template is locked.\n\t\t\t\tif ( getTemplateLock( rootClientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst orientation =\n\t\t\t\t\tgetBlockListSettings( rootClientId )?.orientation ||\n\t\t\t\t\t'vertical';\n\t\t\t\tconst rect = event.target.getBoundingClientRect();\n\t\t\t\tconst offsetTop = event.clientY - rect.top;\n\t\t\t\tconst offsetLeft = event.clientX - rect.left;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockEl.offsetTop > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\tblockEl.offsetLeft > offsetLeft )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter when hovering above (conflicts with\n\t\t\t\t// block toolbar) or inside selected block(s).\n\t\t\t\tif ( getSelectedBlockClientIds().includes( clientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdelayedShowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tisBlockInsertionPointVisible,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"names":["useInBetweenInserter","openRef","InsertionPointOpenRef","isInBetweenInserterDisabled","select","blockEditorStore","getSettings","hasReducedUI","__unstableGetEditorMode","getBlockListSettings","getBlockRootClientId","getBlockIndex","isBlockInsertionPointVisible","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","showInsertionPoint","hideInsertionPoint","delayedShowInsertionPoint","trailing","node","onMouseMove","event","current","target","classList","contains","cancel","rootClientId","blockElement","getAttribute","closest","orientation","offsetTop","clientY","offsetLeft","clientX","children","Array","from","element","find","blockEl","blockElRect","getBoundingClientRect","top","left","id","firstElementChild","clientId","slice","length","includes","elementRect","bottom","right","index","__unstableWithInserter","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIO,SAASA,oBAAT,GAAgC;AACtC,QAAMC,OAAO,GAAG,yBAAYC,qCAAZ,CAAhB;AACA,QAAMC,2BAA2B,GAAG,qBACjCC,MAAF,IACCA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,GAAyCC,YAAzC,IACAH,MAAM,CAAEC,YAAF,CAAN,CAA2BG,uBAA3B,OAAyD,UAHvB,EAInC,EAJmC,CAApC;AAMA,QAAM;AACLC,IAAAA,oBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,4BAJK;AAKLC,IAAAA,gBALK;AAMLC,IAAAA,yBAN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Eb,WAAW,KAAK,UAAhB,KACCV,KAAK,CAACc,OAAN,GAAgBiB,WAAW,CAACE,KAA5B,IACDjC,KAAK,CAACc,OAAN,GAAgBiB,WAAW,CAACP,IAF5B,CAJH,EAOE;AACD5B,QAAAA,yBAAyB,CAACS,MAA1B;;AACA,YAAKhB,4BAA4B,EAAjC,EAAsC;AACrCM,UAAAA,kBAAkB;AAClB;;AACD;AACA;;AAED,YAAMuC,KAAK,GAAG9C,aAAa,CAAEuC,QAAF,CAA3B,CAvG6B,CAyG7B;AACA;;AACA,UAAKO,KAAK,KAAK,CAAf,EAAmB;AAClBtC,QAAAA,yBAAyB,CAACS,MAA1B;;AACA,YAAKhB,4BAA4B,EAAjC,EAAsC;AACrCM,UAAAA,kBAAkB;AAClB;;AACD;AACA;;AAEDC,MAAAA,yBAAyB,CAAEU,YAAF,EAAgB4B,KAAhB,EAAuB;AAC/CC,QAAAA,sBAAsB,EAAE;AADuB,OAAvB,CAAzB;AAGA;;AAEDrC,IAAAA,IAAI,CAACsC,gBAAL,CAAuB,WAAvB,EAAoCrC,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACuC,mBAAL,CAA0B,WAA1B,EAAuCtC,WAAvC;AACA,KAFD;AAGA,GAnIK,EAoIN,CACCrB,OADD,EAECQ,oBAFD,EAGCC,oBAHD,EAICC,aAJD,EAKCC,4BALD,EAMCC,gBAND,EAOCI,kBAPD,EAQCC,kBARD,EASCJ,yBATD,EAUCX,2BAVD,CApIM,CAAP;AAiJA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useDebounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().hasReducedUI ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tisBlockInsertionPointVisible,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t} = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst delayedShowInsertionPoint = useDebounce( showInsertionPoint, 500, {\n\t\ttrailing: true,\n\t} );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\tif ( openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\t// Don't set the insertion point if the template is locked.\n\t\t\t\tif ( getTemplateLock( rootClientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst orientation =\n\t\t\t\t\tgetBlockListSettings( rootClientId )?.orientation ||\n\t\t\t\t\t'vertical';\n\t\t\t\tconst offsetTop = event.clientY;\n\t\t\t\tconst offsetLeft = event.clientX;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\tconst blockElRect = blockEl.getBoundingClientRect();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockElRect.top > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\tblockElRect.left > offsetLeft )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter when hovering above (conflicts with\n\t\t\t\t// block toolbar) or inside selected block(s).\n\t\t\t\tif ( getSelectedBlockClientIds().includes( clientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdelayedShowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tisBlockInsertionPointVisible,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"]}
|
|
@@ -119,7 +119,6 @@ function BlockPopover(_ref, ref) {
|
|
|
119
119
|
return (0, _element.createElement)(_components.Popover, (0, _extends2.default)({
|
|
120
120
|
ref: mergedRefs,
|
|
121
121
|
animate: false,
|
|
122
|
-
position: "top right left",
|
|
123
122
|
focusOnMount: false,
|
|
124
123
|
anchor: popoverAnchor // Render in the old slot if needed for backward compatibility,
|
|
125
124
|
// otherwise render in place (not in the default popover slot).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","style","position","width","offsetWidth","height","offsetHeight","popoverAnchorRecomputeCounter","forceRecomputePopoverAnchor","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","className"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAWA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAIA,MAAMA,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;;AAEA,SAASC,YAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,QADD;AAECC,IAAAA,cAFD;AAGCC,IAAAA,QAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,qBAAqB,GAAG,KALzB;AAMCC,IAAAA,qBAND;AAOCC,IAAAA,oBAPD;AAQC,OAAGC;AARJ,GAWC;AACD,QAAMC,eAAe,GAAG,6CAAiBR,QAAjB,CAAxB;AACA,QAAMS,mBAAmB,GAAG,6CAAiBR,cAAjB,aAAiBA,cAAjB,cAAiBA,cAAjB,GAAmCD,QAAnC,CAA5B;AACA,QAAMU,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or/src/components/block-popover/index.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","style","position","width","offsetWidth","height","offsetHeight","popoverAnchorRecomputeCounter","forceRecomputePopoverAnchor","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","className"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAWA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAIA,MAAMA,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;;AAEA,SAASC,YAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,QADD;AAECC,IAAAA,cAFD;AAGCC,IAAAA,QAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,qBAAqB,GAAG,KALzB;AAMCC,IAAAA,qBAND;AAOCC,IAAAA,oBAPD;AAQC,OAAGC;AARJ,GAWC;AACD,QAAMC,eAAe,GAAG,6CAAiBR,QAAjB,CAAxB;AACA,QAAMS,mBAAmB,GAAG,6CAAiBR,cAAjB,aAAiBA,cAAjB,cAAiBA,cAAjB,GAAmCD,QAAnC,CAA5B;AACA,QAAMU,UAAU,GAAG,2BAAc,CAChCX,GADgC,EAEhC,+BAAkBO,oBAAlB,CAFgC,CAAd,CAAnB;AAIA,QAAMK,KAAK,GAAG,sBAAS,MAAM;AAC5B,QAAK,CAAEH,eAAF,IAAqBC,mBAAmB,KAAKD,eAAlD,EAAoE;AACnE,aAAO,EAAP;AACA;;AAED,WAAO;AACNI,MAAAA,QAAQ,EAAE,UADJ;AAENC,MAAAA,KAAK,EAAEL,eAAe,CAACM,WAFjB;AAGNC,MAAAA,MAA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CAjB5B,EAkBG,CAAEE,qBAAF,IAA2BF,QAlB9B,CADD;AAsBA;;eAEc,yBAAYJ,YAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\tconst style = useMemo( () => {\n\t\tif ( ! selectedElement || lastSelectedElement !== selectedElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [ selectedElement, lastSelectedElement, __unstableRefreshSize ] );\n\n\tconst [ popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor ] =\n\t\tuseReducer(\n\t\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t\t0\n\t\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverAnchor\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverAnchorRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverAnchorRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverAnchorRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"]}
|
|
@@ -158,7 +158,7 @@ function BlockTools(_ref) {
|
|
|
158
158
|
onKeyDown: onKeyDown
|
|
159
159
|
}), (0, _element.createElement)(_insertionPoint.InsertionPointOpenRef.Provider, {
|
|
160
160
|
value: (0, _element.useRef)(false)
|
|
161
|
-
}, !isTyping &&
|
|
161
|
+
}, !isTyping && (0, _element.createElement)(_insertionPoint.default, {
|
|
162
162
|
__unstableContentRef: __unstableContentRef
|
|
163
163
|
}), !isZoomOutMode && (hasFixedToolbar || !isLargeViewport) && (0, _element.createElement)(_blockContextualToolbar.default, {
|
|
164
164
|
isFixed: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"names":["selector","select","__unstableGetEditorMode","getSettings","isTyping","blockEditorStore","isZoomOutMode","hasFixedToolbar","BlockTools","children","__unstableContentRef","props","isLargeViewport","isMatch","getSelectedBlockClientIds","getBlockRootClientId","duplicateBlocks","removeBlocks","insertAfterBlock","insertBeforeBlock","clearSelectedBlock","moveBlocksUp","moveBlocksDown","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","ownerDocument","defaultView","getSelection","removeAllRanges","current","focus","blockToolbarRef","blockToolbarAfterRef"],"mappings":";;;;;;;;;AAOA;;;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAIA;;AACA;;AACA;;AACA;;AACA;;;;;;AApBA;AACA;AACA;;AAOA;AACA;AACA;AAWA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AAAEC,IAAAA,uBAAF;AAA2BC,IAAAA,WAA3B;AAAwCC,IAAAA;AAAxC,MACLH,MAAM,CAAEI,YAAF,CADP;AAGA,SAAO;AACNC,IAAAA,aAAa,EAAEJ,uBAAuB,OAAO,UADvC;AAENK,IAAAA,eAAe,EAAEJ,WAAW,GAAGI,eAFzB;AAGNH,IAAAA,QAAQ,EAAEA,QAAQ;AAHZ,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASI,UAAT,OAIX;AAAA,MAJgC;AACnCC,IAAAA,QADmC;AAEnCC,IAAAA,oBAFmC;AAGnC,OAAGC;AAHgC,GAIhC;AACH,QAAMC,eAAe,GAAG,+BAAkB,QAAlB,CAAxB;AACA,QAAM;AAAEL,IAAAA,eAAF;AAAmBD,IAAAA,aAAnB;AAAkCF,IAAAA;AAAlC,MAA+C,qBACpDJ,QADoD,EAEpD,EAFoD,CAArD;AAIA,QAAMa,OAAO,GAAG,yDAAhB;AACA,QAAM;AAAEC,IAAAA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AAUC,KAAV;AAAkB,MAAA,SAAS,EAAGY;AAA9B,QACC,4BAAC,qCAAD,CAAuB,QAAvB;AAAgC,MAAA,KAAK,EAAG,qBAAQ,KAAR;AAAxC,OACG,CAAEnB,QAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"names":["selector","select","__unstableGetEditorMode","getSettings","isTyping","blockEditorStore","isZoomOutMode","hasFixedToolbar","BlockTools","children","__unstableContentRef","props","isLargeViewport","isMatch","getSelectedBlockClientIds","getBlockRootClientId","duplicateBlocks","removeBlocks","insertAfterBlock","insertBeforeBlock","clearSelectedBlock","moveBlocksUp","moveBlocksDown","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","ownerDocument","defaultView","getSelection","removeAllRanges","current","focus","blockToolbarRef","blockToolbarAfterRef"],"mappings":";;;;;;;;;AAOA;;;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAIA;;AACA;;AACA;;AACA;;AACA;;;;;;AApBA;AACA;AACA;;AAOA;AACA;AACA;AAWA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AAAEC,IAAAA,uBAAF;AAA2BC,IAAAA,WAA3B;AAAwCC,IAAAA;AAAxC,MACLH,MAAM,CAAEI,YAAF,CADP;AAGA,SAAO;AACNC,IAAAA,aAAa,EAAEJ,uBAAuB,OAAO,UADvC;AAENK,IAAAA,eAAe,EAAEJ,WAAW,GAAGI,eAFzB;AAGNH,IAAAA,QAAQ,EAAEA,QAAQ;AAHZ,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASI,UAAT,OAIX;AAAA,MAJgC;AACnCC,IAAAA,QADmC;AAEnCC,IAAAA,oBAFmC;AAGnC,OAAGC;AAHgC,GAIhC;AACH,QAAMC,eAAe,GAAG,+BAAkB,QAAlB,CAAxB;AACA,QAAM;AAAEL,IAAAA,eAAF;AAAmBD,IAAAA,aAAnB;AAAkCF,IA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C,eAAe,GAAG,+BAAkB3B,oBAAlB,CAAxB;AACA,QAAM4B,oBAAoB,GAAG,+BAAkB5B,oBAAlB,CAA7B;AAEA,SACC;AACA,kEAAUC,KAAV;AAAkB,MAAA,SAAS,EAAGY;AAA9B,QACC,4BAAC,qCAAD,CAAuB,QAAvB;AAAgC,MAAA,KAAK,EAAG,qBAAQ,KAAR;AAAxC,OACG,CAAEnB,QAAF,IACD,4BAAC,uBAAD;AACC,MAAA,oBAAoB,EAAGM;AADxB,MAFF,EAMG,CAAEJ,aAAF,KACCC,eAAe,IAAI,CAAEK,eADtB,KAEA,4BAAC,+BAAD;AAAwB,MAAA,OAAO;AAA/B,MARH,EAYC,4BAAC,6BAAD;AACC,MAAA,oBAAoB,EAAGF;AADxB,MAZD,EAgBC,4BAAC,mBAAD,CAAS,IAAT;AAAc,MAAA,IAAI,EAAC,eAAnB;AAAmC,MAAA,GAAG,EAAG2B;AAAzC,MAhBD,EAiBG5B,QAjBH,EAmBC,4BAAC,mBAAD,CAAS,IAAT;AACC,MAAA,IAAI,EAAC,8BADN;AAEC,MAAA,GAAG,EAAG6B;AAFP,MAnBD,EAuBGhC,aAAa,IACd,4BAAC,6BAAD;AACC,MAAA,oBAAoB,EAAGI;AADxB,MAxBF,CADD;AAFD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport SelectedBlockPopover from './selected-block-popover';\nimport { store as blockEditorStore } from '../../store';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\n\nfunction selector( select ) {\n\tconst { __unstableGetEditorMode, getSettings, isTyping } =\n\t\tselect( blockEditorStore );\n\n\treturn {\n\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\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 isLargeViewport = useViewportMatch( 'medium' );\n\tconst { hasFixedToolbar, isZoomOutMode, isTyping } = useSelect(\n\t\tselector,\n\t\t[]\n\t);\n\tconst isMatch = useShortcutEventMatch();\n\tconst { getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tclearSelectedBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) return;\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\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\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\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\tmoveBlocksDown( clientIds, rootClientId );\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/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\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tclearSelectedBlock();\n\t\t\t\tevent.target.ownerDocument.defaultView\n\t\t\t\t\t.getSelection()\n\t\t\t\t\t.removeAllRanges();\n\t\t\t\t__unstableContentRef?.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\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 { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && (\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\t\t\t\t{ ! isZoomOutMode &&\n\t\t\t\t\t( hasFixedToolbar || ! isLargeViewport ) && (\n\t\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t\t) }\n\t\t\t\t{ /* Even if the toolbar is fixed, the block popover is still\n\t\t\t\t\tneeded for navigation and zoom-out mode. */ }\n\t\t\t\t<SelectedBlockPopover\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t/>\n\t\t\t\t{ /* Used for the inline rich text toolbar. */ }\n\t\t\t\t<Popover.Slot name=\"block-toolbar\" ref={ blockToolbarRef } />\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 && (\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</div>\n\t);\n}\n"]}
|
|
@@ -22,10 +22,13 @@ var _useBlockRefs = require("../block-list/use-block-props/use-block-refs");
|
|
|
22
22
|
/**
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
const COMMON_PROPS = {
|
|
26
|
+
placement: 'top-start'
|
|
27
|
+
}; // By default the toolbar sets the `shift` prop. If the user scrolls the page
|
|
26
28
|
// down the toolbar will stay on screen by adopting a sticky position at the
|
|
27
29
|
// top of the viewport.
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
const DEFAULT_PROPS = { ...COMMON_PROPS,
|
|
29
32
|
flip: false,
|
|
30
33
|
shift: true
|
|
31
34
|
}; // When there isn't enough height between the top of the block and the editor
|
|
@@ -34,7 +37,7 @@ const DEFAULT_PROPS = {
|
|
|
34
37
|
// the block. This only happens if the block is smaller than the viewport, as
|
|
35
38
|
// otherwise the toolbar will be off-screen.
|
|
36
39
|
|
|
37
|
-
const RESTRICTED_HEIGHT_PROPS = {
|
|
40
|
+
const RESTRICTED_HEIGHT_PROPS = { ...COMMON_PROPS,
|
|
38
41
|
flip: true,
|
|
39
42
|
shift: false
|
|
40
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["DEFAULT_PROPS","flip","shift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","viewportHeight","ownerDocument","documentElement","clientHeight","hasSpaceForToolbarAbove","top","isBlockTallerThanViewport","height","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","blockEditorStore","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["COMMON_PROPS","placement","DEFAULT_PROPS","flip","shift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","viewportHeight","ownerDocument","documentElement","clientHeight","hasSpaceForToolbarAbove","top","isBlockTallerThanViewport","height","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","blockEditorStore","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","remov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BAAH,gDAAGA,oBAAoB,CAAEM,aAAzB,0DAAG,sBAAqCqB,WAAvD;;AACA,QAAKG,SAAS,CAACC,cAAf,EAAgC;AAC/BF,MAAAA,cAAc,GAAG,IAAIC,SAAS,CAACC,cAAd,CAA8BN,WAA9B,CAAjB;AACAI,MAAAA,cAAc,CAACG,OAAf,CAAwBhC,oBAAxB;AACA;;AAED,WAAO,MAAM;AAAA;;AACZ0B,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,qCAAAA,WAAW,CAAEO,kBAAb,qFAAAP,WAAW,EAAwB,QAAxB,EAAkCD,WAAlC,CAAX;;AAEA,UAAKI,cAAL,EAAsB;AACrBA,QAAAA,cAAc,CAACK,UAAf;AACA;AACD,KAND;AAOA,GAxBD,EAwBG,CAAET,WAAF,EAAe1B,cAAf,EAA+BC,oBAA/B,CAxBH;AA0BA,SAAO,EACN,GAAGgB,KADG;AAENmB,IAAAA,GAAG,EAAEb;AAFC,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\n\nconst COMMON_PROPS = {\n\tplacement: 'top-start',\n};\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: false,\n\tshift: true,\n};\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled, which positions the toolbar below\n// the block. This only happens if the block is smaller than the viewport, as\n// otherwise the toolbar will be off-screen.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: true,\n\tshift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps( contentElement, selectedBlockElement, toolbarHeight ) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\tconst blockRect = selectedBlockElement.getBoundingClientRect();\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\t// The document element's clientHeight represents the viewport height.\n\tconst viewportHeight =\n\t\tcontentElement.ownerDocument.documentElement.clientHeight;\n\n\tconst hasSpaceForToolbarAbove =\n\t\tblockRect.top - contentRect.top > toolbarHeight;\n\tconst isBlockTallerThanViewport =\n\t\tblockRect.height > viewportHeight - toolbarHeight;\n\n\tif ( hasSpaceForToolbarAbove || isBlockTallerThanViewport ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t);\n\tconst blockIndex = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockIndex( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"]}
|
|
@@ -124,6 +124,7 @@ var _exportNames = {
|
|
|
124
124
|
__experimentalBlockPatternsList: true,
|
|
125
125
|
__experimentalPublishDateTimePicker: true,
|
|
126
126
|
__experimentalInspectorPopoverHeader: true,
|
|
127
|
+
__experimentalUseOnBlockDrop: true,
|
|
127
128
|
BlockEditorProvider: true,
|
|
128
129
|
useSetting: true
|
|
129
130
|
};
|
|
@@ -733,6 +734,12 @@ Object.defineProperty(exports, "__experimentalUseMultipleOriginColorsAndGradient
|
|
|
733
734
|
return _useMultipleOriginColorsAndGradients.default;
|
|
734
735
|
}
|
|
735
736
|
});
|
|
737
|
+
Object.defineProperty(exports, "__experimentalUseOnBlockDrop", {
|
|
738
|
+
enumerable: true,
|
|
739
|
+
get: function () {
|
|
740
|
+
return _useOnBlockDrop.default;
|
|
741
|
+
}
|
|
742
|
+
});
|
|
736
743
|
Object.defineProperty(exports, "__experimentalUseResizeCanvas", {
|
|
737
744
|
enumerable: true,
|
|
738
745
|
get: function () {
|
|
@@ -1100,6 +1107,8 @@ var _publishDateTimePicker = _interopRequireDefault(require("./publish-date-time
|
|
|
1100
1107
|
|
|
1101
1108
|
var _inspectorPopoverHeader = _interopRequireDefault(require("./inspector-popover-header"));
|
|
1102
1109
|
|
|
1110
|
+
var _useOnBlockDrop = _interopRequireDefault(require("./use-on-block-drop"));
|
|
1111
|
+
|
|
1103
1112
|
var _provider = _interopRequireDefault(require("./provider"));
|
|
1104
1113
|
|
|
1105
1114
|
var _useSetting = _interopRequireDefault(require("./use-setting"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAMA;;AACA","sourcesContent":["/*\n * Block Creation Components\n */\n\nexport * from './colors';\nexport * from './gradients';\nexport * from './font-sizes';\nexport * from './duotone';\nexport { AlignmentControl, AlignmentToolbar } from './alignment-control';\nexport { default as Autocomplete } from './autocomplete';\nexport {\n\tBlockAlignmentControl,\n\tBlockAlignmentToolbar,\n} from './block-alignment-control';\nexport { default as __experimentalBlockFullHeightAligmentControl } from './block-full-height-alignment-control';\nexport { default as __experimentalBlockAlignmentMatrixControl } from './block-alignment-matrix-control';\nexport { default as BlockBreadcrumb } from './block-breadcrumb';\nexport { default as __experimentalUseBlockOverlayActive } from './block-content-overlay';\nexport { BlockContextProvider } from './block-context';\nexport {\n\tdefault as BlockControls,\n\tBlockFormatControls,\n} from './block-controls';\nexport { default as BlockColorsStyleSelector } from './color-style-selector';\nexport { default as BlockEdit, useBlockEditContext } from './block-edit';\nexport { default as BlockIcon } from './block-icon';\nexport { default as BlockNavigationDropdown } from './block-navigation/dropdown';\nexport { default as BlockStyles } from './block-styles';\nexport { default as __experimentalBlockVariationPicker } from './block-variation-picker';\nexport { default as __experimentalBlockPatternSetup } from './block-pattern-setup';\nexport { default as __experimentalBlockVariationTransforms } from './block-variation-transforms';\nexport {\n\tBlockVerticalAlignmentToolbar,\n\tBlockVerticalAlignmentControl,\n} from './block-vertical-alignment-control';\nexport { default as __experimentalBorderRadiusControl } from './border-radius-control';\nexport {\n\t// This is a typo, but kept here for back-compat.\n\tButtonBlockerAppender,\n\tdefault as ButtonBlockAppender,\n} from './button-block-appender';\nexport { default as ColorPalette } from './color-palette';\nexport { default as ColorPaletteControl } from './color-palette/control';\nexport { default as ContrastChecker } from './contrast-checker';\nexport { default as __experimentalDateFormatPicker } from './date-format-picker';\nexport { default as __experimentalDuotoneControl } from './duotone-control';\nexport { default as __experimentalFontAppearanceControl } from './font-appearance-control';\nexport { default as __experimentalFontFamilyControl } from './font-family';\nexport { default as __experimentalLetterSpacingControl } from './letter-spacing-control';\nexport { default as __experimentalTextDecorationControl } from './text-decoration-control';\nexport { default as __experimentalTextTransformControl } from './text-transform-control';\nexport { default as __experimentalColorGradientControl } from './colors-gradients/control';\nexport { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';\nexport { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';\nexport { default as __experimentalUseMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';\nexport {\n\tdefault as __experimentalImageEditor,\n\tImageEditingProvider as __experimentalImageEditingProvider,\n} from './image-editor';\nexport { default as __experimentalImageSizeControl } from './image-size-control';\nexport { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';\nexport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from './inspector-controls';\nexport {\n\tJustifyToolbar,\n\tJustifyContentControl,\n} from './justify-content-control';\nexport { default as __experimentalLinkControl } from './link-control';\nexport { default as __experimentalLinkControlSearchInput } from './link-control/search-input';\nexport { default as __experimentalLinkControlSearchResults } from './link-control/search-results';\nexport { default as __experimentalLinkControlSearchItem } from './link-control/search-item';\nexport { default as LineHeightControl } from './line-height-control';\nexport { default as __experimentalListView } from './list-view';\nexport { default as MediaReplaceFlow } from './media-replace-flow';\nexport { default as MediaPlaceholder } from './media-placeholder';\nexport { default as MediaUpload } from './media-upload';\nexport { default as MediaUploadCheck } from './media-upload/check';\nexport { default as PanelColorSettings } from './panel-color-settings';\nexport { default as PlainText } from './plain-text';\nexport { default as __experimentalResponsiveBlockControl } from './responsive-block-control';\nexport {\n\tdefault as RichText,\n\tRichTextShortcut,\n\tRichTextToolbarButton,\n\t__unstableRichTextInputEvent,\n} from './rich-text';\nexport { default as ToolSelector } from './tool-selector';\nexport { default as __experimentalUnitControl } from './unit-control';\nexport { default as URLInput } from './url-input';\nexport { default as URLInputButton } from './url-input/button';\nexport { default as URLPopover } from './url-popover';\nexport { __experimentalImageURLInputUI } from './url-popover/image-url-input-ui';\nexport { default as withColorContext } from './color-palette/with-color-context';\nexport { default as __experimentalSpacingSizesControl } from './spacing-sizes-control';\n\n/*\n * Content Related Components\n */\n\nexport { default as __unstableBlockSettingsMenuFirstItem } from './block-settings-menu/block-settings-menu-first-item';\nexport { default as __unstableBlockToolbarLastItem } from './block-toolbar/block-toolbar-last-item';\nexport { default as __unstableBlockNameContext } from './block-toolbar/block-name-context';\nexport { default as __unstableInserterMenuExtension } from './inserter-menu-extension';\nexport { default as __experimentalPreviewOptions } from './preview-options';\nexport { default as __experimentalUseResizeCanvas } from './use-resize-canvas';\nexport { default as BlockInspector } from './block-inspector';\nexport { default as BlockList } from './block-list';\nexport { useBlockProps } from './block-list/use-block-props';\nexport { LayoutStyle as __experimentalLayoutStyle } from './block-list/layout';\nexport { default as BlockMover } from './block-mover';\nexport {\n\tdefault as BlockPreview,\n\tuseBlockPreview as __experimentalUseBlockPreview,\n} from './block-preview';\nexport {\n\tdefault as BlockSelectionClearer,\n\tuseBlockSelectionClearer as __unstableUseBlockSelectionClearer,\n} from './block-selection-clearer';\nexport { default as BlockSettingsMenu } from './block-settings-menu';\nexport { default as BlockSettingsMenuControls } from './block-settings-menu-controls';\nexport { default as BlockTitle } from './block-title';\nexport { default as BlockToolbar } from './block-toolbar';\nexport { default as BlockTools } from './block-tools';\nexport {\n\tdefault as CopyHandler,\n\tuseClipboardHandler as __unstableUseClipboardHandler,\n} from './copy-handler';\nexport { default as DefaultBlockAppender } from './default-block-appender';\nexport { default as __unstableEditorStyles } from './editor-styles';\nexport { default as Inserter } from './inserter';\nexport { default as __experimentalLibrary } from './inserter/library';\nexport { default as BlockEditorKeyboardShortcuts } from './keyboard-shortcuts';\nexport { MultiSelectScrollIntoView } from './selection-scroll-into-view';\nexport { default as NavigableToolbar } from './navigable-toolbar';\nexport {\n\tdefault as ObserveTyping,\n\tuseTypingObserver as __unstableUseTypingObserver,\n\tuseMouseMoveTypingReset as __unstableUseMouseMoveTypingReset,\n} from './observe-typing';\nexport { default as SkipToSelectedBlock } from './skip-to-selected-block';\nexport {\n\tdefault as Typewriter,\n\tuseTypewriter as __unstableUseTypewriter,\n} from './typewriter';\nexport { default as Warning } from './warning';\nexport { default as WritingFlow } from './writing-flow';\nexport { default as useBlockDisplayInformation } from './use-block-display-information';\nexport { default as __unstableIframe } from './iframe';\nexport {\n\tRecursionProvider as __experimentalRecursionProvider,\n\tuseHasRecursion as __experimentalUseHasRecursion,\n} from './recursion-provider';\nexport { default as __experimentalBlockPatternsList } from './block-patterns-list';\nexport { default as __experimentalPublishDateTimePicker } from './publish-date-time-picker';\nexport { default as __experimentalInspectorPopoverHeader } from './inspector-popover-header';\n\n/*\n * State Related Components\n */\n\nexport { default as BlockEditorProvider } from './provider';\nexport { default as useSetting } from './use-setting';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AAMA;;AACA","sourcesContent":["/*\n * Block Creation Components\n */\n\nexport * from './colors';\nexport * from './gradients';\nexport * from './font-sizes';\nexport * from './duotone';\nexport { AlignmentControl, AlignmentToolbar } from './alignment-control';\nexport { default as Autocomplete } from './autocomplete';\nexport {\n\tBlockAlignmentControl,\n\tBlockAlignmentToolbar,\n} from './block-alignment-control';\nexport { default as __experimentalBlockFullHeightAligmentControl } from './block-full-height-alignment-control';\nexport { default as __experimentalBlockAlignmentMatrixControl } from './block-alignment-matrix-control';\nexport { default as BlockBreadcrumb } from './block-breadcrumb';\nexport { default as __experimentalUseBlockOverlayActive } from './block-content-overlay';\nexport { BlockContextProvider } from './block-context';\nexport {\n\tdefault as BlockControls,\n\tBlockFormatControls,\n} from './block-controls';\nexport { default as BlockColorsStyleSelector } from './color-style-selector';\nexport { default as BlockEdit, useBlockEditContext } from './block-edit';\nexport { default as BlockIcon } from './block-icon';\nexport { default as BlockNavigationDropdown } from './block-navigation/dropdown';\nexport { default as BlockStyles } from './block-styles';\nexport { default as __experimentalBlockVariationPicker } from './block-variation-picker';\nexport { default as __experimentalBlockPatternSetup } from './block-pattern-setup';\nexport { default as __experimentalBlockVariationTransforms } from './block-variation-transforms';\nexport {\n\tBlockVerticalAlignmentToolbar,\n\tBlockVerticalAlignmentControl,\n} from './block-vertical-alignment-control';\nexport { default as __experimentalBorderRadiusControl } from './border-radius-control';\nexport {\n\t// This is a typo, but kept here for back-compat.\n\tButtonBlockerAppender,\n\tdefault as ButtonBlockAppender,\n} from './button-block-appender';\nexport { default as ColorPalette } from './color-palette';\nexport { default as ColorPaletteControl } from './color-palette/control';\nexport { default as ContrastChecker } from './contrast-checker';\nexport { default as __experimentalDateFormatPicker } from './date-format-picker';\nexport { default as __experimentalDuotoneControl } from './duotone-control';\nexport { default as __experimentalFontAppearanceControl } from './font-appearance-control';\nexport { default as __experimentalFontFamilyControl } from './font-family';\nexport { default as __experimentalLetterSpacingControl } from './letter-spacing-control';\nexport { default as __experimentalTextDecorationControl } from './text-decoration-control';\nexport { default as __experimentalTextTransformControl } from './text-transform-control';\nexport { default as __experimentalColorGradientControl } from './colors-gradients/control';\nexport { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';\nexport { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';\nexport { default as __experimentalUseMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';\nexport {\n\tdefault as __experimentalImageEditor,\n\tImageEditingProvider as __experimentalImageEditingProvider,\n} from './image-editor';\nexport { default as __experimentalImageSizeControl } from './image-size-control';\nexport { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';\nexport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from './inspector-controls';\nexport {\n\tJustifyToolbar,\n\tJustifyContentControl,\n} from './justify-content-control';\nexport { default as __experimentalLinkControl } from './link-control';\nexport { default as __experimentalLinkControlSearchInput } from './link-control/search-input';\nexport { default as __experimentalLinkControlSearchResults } from './link-control/search-results';\nexport { default as __experimentalLinkControlSearchItem } from './link-control/search-item';\nexport { default as LineHeightControl } from './line-height-control';\nexport { default as __experimentalListView } from './list-view';\nexport { default as MediaReplaceFlow } from './media-replace-flow';\nexport { default as MediaPlaceholder } from './media-placeholder';\nexport { default as MediaUpload } from './media-upload';\nexport { default as MediaUploadCheck } from './media-upload/check';\nexport { default as PanelColorSettings } from './panel-color-settings';\nexport { default as PlainText } from './plain-text';\nexport { default as __experimentalResponsiveBlockControl } from './responsive-block-control';\nexport {\n\tdefault as RichText,\n\tRichTextShortcut,\n\tRichTextToolbarButton,\n\t__unstableRichTextInputEvent,\n} from './rich-text';\nexport { default as ToolSelector } from './tool-selector';\nexport { default as __experimentalUnitControl } from './unit-control';\nexport { default as URLInput } from './url-input';\nexport { default as URLInputButton } from './url-input/button';\nexport { default as URLPopover } from './url-popover';\nexport { __experimentalImageURLInputUI } from './url-popover/image-url-input-ui';\nexport { default as withColorContext } from './color-palette/with-color-context';\nexport { default as __experimentalSpacingSizesControl } from './spacing-sizes-control';\n\n/*\n * Content Related Components\n */\n\nexport { default as __unstableBlockSettingsMenuFirstItem } from './block-settings-menu/block-settings-menu-first-item';\nexport { default as __unstableBlockToolbarLastItem } from './block-toolbar/block-toolbar-last-item';\nexport { default as __unstableBlockNameContext } from './block-toolbar/block-name-context';\nexport { default as __unstableInserterMenuExtension } from './inserter-menu-extension';\nexport { default as __experimentalPreviewOptions } from './preview-options';\nexport { default as __experimentalUseResizeCanvas } from './use-resize-canvas';\nexport { default as BlockInspector } from './block-inspector';\nexport { default as BlockList } from './block-list';\nexport { useBlockProps } from './block-list/use-block-props';\nexport { LayoutStyle as __experimentalLayoutStyle } from './block-list/layout';\nexport { default as BlockMover } from './block-mover';\nexport {\n\tdefault as BlockPreview,\n\tuseBlockPreview as __experimentalUseBlockPreview,\n} from './block-preview';\nexport {\n\tdefault as BlockSelectionClearer,\n\tuseBlockSelectionClearer as __unstableUseBlockSelectionClearer,\n} from './block-selection-clearer';\nexport { default as BlockSettingsMenu } from './block-settings-menu';\nexport { default as BlockSettingsMenuControls } from './block-settings-menu-controls';\nexport { default as BlockTitle } from './block-title';\nexport { default as BlockToolbar } from './block-toolbar';\nexport { default as BlockTools } from './block-tools';\nexport {\n\tdefault as CopyHandler,\n\tuseClipboardHandler as __unstableUseClipboardHandler,\n} from './copy-handler';\nexport { default as DefaultBlockAppender } from './default-block-appender';\nexport { default as __unstableEditorStyles } from './editor-styles';\nexport { default as Inserter } from './inserter';\nexport { default as __experimentalLibrary } from './inserter/library';\nexport { default as BlockEditorKeyboardShortcuts } from './keyboard-shortcuts';\nexport { MultiSelectScrollIntoView } from './selection-scroll-into-view';\nexport { default as NavigableToolbar } from './navigable-toolbar';\nexport {\n\tdefault as ObserveTyping,\n\tuseTypingObserver as __unstableUseTypingObserver,\n\tuseMouseMoveTypingReset as __unstableUseMouseMoveTypingReset,\n} from './observe-typing';\nexport { default as SkipToSelectedBlock } from './skip-to-selected-block';\nexport {\n\tdefault as Typewriter,\n\tuseTypewriter as __unstableUseTypewriter,\n} from './typewriter';\nexport { default as Warning } from './warning';\nexport { default as WritingFlow } from './writing-flow';\nexport { default as useBlockDisplayInformation } from './use-block-display-information';\nexport { default as __unstableIframe } from './iframe';\nexport {\n\tRecursionProvider as __experimentalRecursionProvider,\n\tuseHasRecursion as __experimentalUseHasRecursion,\n} from './recursion-provider';\nexport { default as __experimentalBlockPatternsList } from './block-patterns-list';\nexport { default as __experimentalPublishDateTimePicker } from './publish-date-time-picker';\nexport { default as __experimentalInspectorPopoverHeader } from './inspector-popover-header';\nexport { default as __experimentalUseOnBlockDrop } from './use-on-block-drop';\n\n/*\n * State Related Components\n */\n\nexport { default as BlockEditorProvider } from './provider';\nexport { default as useSetting } from './use-setting';\n"]}
|
|
@@ -221,7 +221,7 @@ const ImageURLInputUI = _ref => {
|
|
|
221
221
|
onChange: onSetNewTab,
|
|
222
222
|
checked: linkTarget === '_blank'
|
|
223
223
|
}), (0, _element.createElement)(_components.TextControl, {
|
|
224
|
-
label: (0, _i18n.__)('Link
|
|
224
|
+
label: (0, _i18n.__)('Link rel'),
|
|
225
225
|
value: rel !== null && rel !== void 0 ? rel : '',
|
|
226
226
|
onChange: onSetLinkRel
|
|
227
227
|
}), (0, _element.createElement)(_components.TextControl, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"names":["LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","icon","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","current","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","find","destination","href","preventDefault","onLinkRemove","linkDestinations","title","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","linkEditorValue","urlLabel","linkIcon","link","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAUA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,MAA9B;AACA,MAAMC,uBAAuB,GAAG,QAAhC;AACA,MAAMC,sBAAsB,GAAG,OAA/B;AACA,MAAMC,2BAA2B,GAAG,YAApC;AACA,MAAMC,WAAW,GAAG,CAAE,YAAF,EAAgB,UAAhB,CAApB;AAEA,MAAMC,IAAI,GACT,4BAAC,eAAD;AAAK,EAAA,OAAO,EAAC,WAAb;AAAyB,EAAA,KAAK,EAAC;AAA/B,GACC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC,iBAAR;AAA0B,EAAA,IAAI,EAAC;AAA/B,EADD,EAEC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EAFD,EAGC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EAHD,CADD;;AAQA,MAAMC,eAAe,GAAG,QAUjB;AAAA,MAVmB;AACzBC,IAAAA,eADyB;AAEzBC,IAAAA,WAFyB;AAGzBC,IAAAA,GAHyB;AAIzBC,IAAAA,SAAS,GAAG,OAJa;AAKzBC,IAAAA,QALyB;AAMzBC,IAAAA,SANyB;AAOzBC,IAAAA,UAPyB;AAQzBC,IAAAA,SARyB;AASzBC,IAAAA;AATyB,GAUnB;AACN,QAAM,CAAEC,MAAF,E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AASY,aAAX,KACD,4BAAC,cAAD,CAAY,UAAZ;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,KAAK,EAAG6C,eAFT;AAGC,IAAA,kBAAkB,EAAG1C,WAHtB;AAIC,IAAA,QAAQ,EAAGyB,kBAAkB,EAJ9B;AAKC,IAAA,eAAe,EAAGxB;AALnB,IA1BF,EAkCGhB,GAAG,IAAI,CAAEY,aAAT,IACD,qDACC,4BAAC,cAAD,CAAY,UAAZ;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,GAAG,EAAGZ,GAFP;AAGC,IAAA,eAAe,EAAGiB,aAHnB;AAIC,IAAA,QAAQ,EAAGyC;AAJZ,IADD,EAOC,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGG,YADR;AAEC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,IAAA,OAAO,EAAGd;AAHX,IAPD,CAnCF,CAVF,CADD;AAgEA,CAzQD","sourcesContent":["/**\n * External dependencies\n */\nimport { find, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useCallback } from '@wordpress/element';\nimport {\n\tToolbarButton,\n\tButton,\n\tNavigableMenu,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { link as linkIcon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst icon = (\n\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path d=\"M0,0h24v24H0V0z\" fill=\"none\" />\n\t\t<Path d=\"m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z\" />\n\t\t<Path d=\"m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z\" />\n\t</SVG>\n);\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = useCallback( () => {\n\t\tsetIsOpen( true );\n\t} );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\n\tconst startEditLink = useCallback( () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t} );\n\n\tconst stopEditLink = useCallback( () => {\n\t\tsetIsEditingLink( false );\n\t} );\n\n\tconst closeLinkUI = useCallback( () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t} );\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t} );\n\n\tconst onSubmitLinkChange = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t} );\n\n\tconst onLinkRemove = useCallback( () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t} );\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Media File' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Attachment Page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: (\n\t\t\t\t\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<Path d=\"M0 0h24v24H0V0z\" fill=\"none\" />\n\t\t\t\t\t\t<Path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z\" />\n\t\t\t\t\t</SVG>\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tfind( linkDestinations, ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link Rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS Class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\n\tconst urlLabel = (\n\t\tfind( getLinkDestinations(), [ 'linkDestination', linkDestination ] ) ||\n\t\t{}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ url ? __( 'Edit link' ) : __( 'Insert link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={ () => advancedOptions }\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\t! linkEditorValue && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ map( getLinkDestinations(), ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && (\n\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"names":["LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","icon","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","current","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","find","destination","href","preventDefault","onLinkRemove","linkDestinations","title","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","linkEditorValue","urlLabel","linkIcon","link","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAUA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,MAA9B;AACA,MAAMC,uBAAuB,GAAG,QAAhC;AACA,MAAMC,sBAAsB,GAAG,OAA/B;AACA,MAAMC,2BAA2B,GAAG,YAApC;AACA,MAAMC,WAAW,GAAG,CAAE,YAAF,EAAgB,UAAhB,CAApB;AAEA,MAAMC,IAAI,GACT,4BAAC,eAAD;AAAK,EAAA,OAAO,EAAC,WAAb;AAAyB,EAAA,KAAK,EAAC;AAA/B,GACC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC,iBAAR;AAA0B,EAAA,IAAI,EAAC;AAA/B,EADD,EAEC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EAFD,EAGC,4BAAC,gBAAD;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4BAAC,oBAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAAC9D,eADZ;AAEC,MAAA,IAAI,EAAG8D,IAAI,CAAChE,IAFb;AAGC,MAAA,OAAO,EAAG,MAAM;AACfmB,QAAAA,WAAW,CAAE,IAAF,CAAX;AACAmC,QAAAA,SAAS,CAAEU,IAAI,CAAC5D,GAAP,CAAT;AACAkB,QAAAA,YAAY;AACZ;AAPF,OASG0C,IAAI,CAACX,KATR,CADC,CADH;AAPH,KAyBG,CAAE,CAAEjD,GAAF,IAASY,aAAX,KACD,4BAAC,cAAD,CAAY,UAAZ;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,KAAK,EAAG6C,eAFT;AAGC,IAAA,kBAAkB,EAAG1C,WAHtB;AAIC,IAAA,QAAQ,EAAGyB,kBAAkB,EAJ9B;AAKC,IAAA,eAAe,EAAGxB;AALnB,IA1BF,EAkCGhB,GAAG,IAAI,CAAEY,aAAT,IACD,qDACC,4BAAC,cAAD,CAAY,UAAZ;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,GAAG,EAAGZ,GAFP;AAGC,IAAA,eAAe,EAAGiB,aAHnB;AAIC,IAAA,QAAQ,EAAGyC;AAJZ,IADD,EAOC,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGG,YADR;AAEC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,IAAA,OAAO,EAAGd;AAHX,IAPD,CAnCF,CAVF,CADD;AAgEA,CAzQD","sourcesContent":["/**\n * External dependencies\n */\nimport { find, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useCallback } from '@wordpress/element';\nimport {\n\tToolbarButton,\n\tButton,\n\tNavigableMenu,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { link as linkIcon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst icon = (\n\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path d=\"M0,0h24v24H0V0z\" fill=\"none\" />\n\t\t<Path d=\"m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z\" />\n\t\t<Path d=\"m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z\" />\n\t</SVG>\n);\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = useCallback( () => {\n\t\tsetIsOpen( true );\n\t} );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\n\tconst startEditLink = useCallback( () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t} );\n\n\tconst stopEditLink = useCallback( () => {\n\t\tsetIsEditingLink( false );\n\t} );\n\n\tconst closeLinkUI = useCallback( () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t} );\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t} );\n\n\tconst onSubmitLinkChange = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t} );\n\n\tconst onLinkRemove = useCallback( () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t} );\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Media File' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Attachment Page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: (\n\t\t\t\t\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<Path d=\"M0 0h24v24H0V0z\" fill=\"none\" />\n\t\t\t\t\t\t<Path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z\" />\n\t\t\t\t\t</SVG>\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tfind( linkDestinations, ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS Class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\n\tconst urlLabel = (\n\t\tfind( getLinkDestinations(), [ 'linkDestination', linkDestination ] ) ||\n\t\t{}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ url ? __( 'Edit link' ) : __( 'Insert link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={ () => advancedOptions }\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\t! linkEditorValue && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ map( getLinkDestinations(), ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && (\n\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"]}
|
|
@@ -71,6 +71,17 @@ function getNearestBlockIndex(elements, position, orientation) {
|
|
|
71
71
|
});
|
|
72
72
|
return candidateIndex;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Determine if the element is an empty paragraph block.
|
|
76
|
+
*
|
|
77
|
+
* @param {?HTMLElement} element The element being tested.
|
|
78
|
+
* @return {boolean} True or False.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
function isEmptyParagraph(element) {
|
|
83
|
+
return !!element && element.dataset.type === 'core/paragraph' && element.dataset.empty === 'true';
|
|
84
|
+
}
|
|
74
85
|
/**
|
|
75
86
|
* @typedef {Object} WPBlockDropZoneConfig
|
|
76
87
|
* @property {string} rootClientId The root client id for the block list.
|
|
@@ -120,7 +131,14 @@ function useBlockDropZone() {
|
|
|
120
131
|
}, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation);
|
|
121
132
|
setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
|
|
122
133
|
|
|
123
|
-
if (targetIndex !==
|
|
134
|
+
if (targetIndex !== undefined) {
|
|
135
|
+
const nextBlock = blockElements[targetIndex];
|
|
136
|
+
const previousBlock = blockElements[targetIndex - 1]; // Don't show the insertion point when it's near an empty paragraph block.
|
|
137
|
+
|
|
138
|
+
if (isEmptyParagraph(nextBlock) || isEmptyParagraph(previousBlock)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
124
142
|
showInsertionPoint(targetRootClientId, targetIndex);
|
|
125
143
|
}
|
|
126
144
|
}, []), 200);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"names":["getNearestBlockIndex","elements","position","orientation","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","rect","getBoundingClientRect","distance","edge","undefined","isTrailingEdge","offset","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","setTargetBlockIndex","isDisabled","select","getTemplateLock","__unstableIsWithinBlockOverlay","__unstableHasActiveBlockOverlayActive","blockEditorStore","templateLock","some","lock","getBlockListSettings","showInsertionPoint","hideInsertionPoint","onBlockDrop","throttled","event","currentTarget","blockElements","Array","from","children","filter","classList","contains","targetIndex","x","clientX","y","clientY","onDrop","onDragOver","onDragLeave","cancel","onDragEnd"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AASA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA+BC,QAA/B,EAAyCC,QAAzC,EAAmDC,WAAnD,EAAiE;AACvE,QAAMC,YAAY,GACjBD,WAAW,KAAK,YAAhB,GACG,CAAE,MAAF,EAAU,OAAV,CADH,GAEG,CAAE,KAAF,EAAS,QAAT,CAHJ;AAKA,QAAME,aAAa,GAAG,kBAAtB;AAEA,MAAIC,cAAJ;AACA,MAAIC,iBAAJ;AAEAN,EAAAA,QAAQ,CAACO,OAAT,CAAkB,CAAEC,OAAF,EAAWC,KAAX,KAAsB;AACvC,UAAMC,IAAI,GAAGF,OAAO,CAACG,qBAAR,EAAb;AACA,UAAM,CAAEC,QAAF,EAAYC,IAAZ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AA,SAAS,GAAG;AACXnB,MAAAA,SAAS,CAACkB,MAAV;AACApB,MAAAA,kBAAkB;AAClBZ,MAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA;;AAlBkB,GAAb,CAAP;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of block DOM elements finds the index that a block should be dropped\n * at.\n *\n * @param {Element[]} elements Array of DOM elements that represent each block in a block list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex( elements, position, orientation ) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\telements.forEach( ( element, index ) => {\n\t\tconst rect = element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\n\treturn candidateIndex;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst [ targetBlockIndex, setTargetBlockIndex ] = useState( null );\n\n\tconst isDisabled = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetTemplateLock,\n\t\t\t\t__unstableIsWithinBlockOverlay,\n\t\t\t\t__unstableHasActiveBlockOverlayActive,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst templateLock = getTemplateLock( targetRootClientId );\n\t\t\treturn (\n\t\t\t\t[ 'all', 'contentOnly' ].some(\n\t\t\t\t\t( lock ) => lock === templateLock\n\t\t\t\t) ||\n\t\t\t\t__unstableHasActiveBlockOverlayActive( targetRootClientId ) ||\n\t\t\t\t__unstableIsWithinBlockOverlay( targetRootClientId )\n\t\t\t);\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings } = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\tconst throttled = useThrottle(\n\t\tuseCallback( ( event, currentTarget ) => {\n\t\t\tconst blockElements = Array.from( currentTarget.children ).filter(\n\t\t\t\t// Ensure the element is a block. It should have the `wp-block` class.\n\t\t\t\t( element ) => element.classList.contains( 'wp-block' )\n\t\t\t);\n\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\tblockElements,\n\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t);\n\n\t\t\tsetTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );\n\n\t\t\tif ( targetIndex !== null ) {\n\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex );\n\t\t\t}\n\t\t}, [] ),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"names":["getNearestBlockIndex","elements","position","orientation","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","rect","getBoundingClientRect","distance","edge","undefined","isTrailingEdge","offset","isEmptyParagraph","dataset","type","empty","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","setTargetBlockIndex","isDisabled","select","getTemplateLock","__unstableIsWithinBlockOverlay","__unstableHasActiveBlockOverlayActive","blockEditorStore","templateLock","some","lock","getBlockListSettings","showInsertionPoint","hideInsertionPoint","onBlockDrop","throttled","event","currentTarget","blockElements","Array","from","children","filter","classList","contains","targetIndex","x","clientX","y","clientY","nextBlock","previousBlock","onDrop","onDragOver","onDragLeave","cancel","onDragEnd"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AASA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA+BC,QAA/B,EAAyCC,QAAzC,EAAmDC,WAAnD,EAAiE;AACvE,QAAMC,YAAY,GACjBD,WAAW,KAAK,YAAhB,GACG,CAAE,MAAF,EAAU,OAAV,CADH,GAEG,CAAE,KAAF,EAAS,QAAT,CAHJ;AAKA,QAAME,aAAa,GAAG,kBAAtB;AAEA,MAAIC,cAAJ;AACA,MAAIC,iBAAJ;AAEAN,EAAAA,QAAQ,CAACO,OAAT,CAAkB,CAAEC,OAAF,EAAWC,KAAX,KAAsB;AACvC,UAAMC,IAAI,GAAGF,OAAO,CAACG,qBAAR,EAAb;AACA,UAAM,CAAEC,QAAF,EAAYC,IAAZ,IAAqB,oCAC1BZ,QAD0B,EAE1BS,IAF0B,EAG1BP,YAH0B,CAA3B;;AAMA,QAAKG,iBAAiB,KAAKQ,SAAtB,IAAmCF,QAAQ,GAAGN,iBAAnD,EAAuE;AACtE;AACA;AACA;AACA;AACA,YAAMS,cAAc,GACnBF,IAAI,KAAK,QAAT,IACE,CAAET,aAAF,IAAmBS,IAAI,KAAK,OAD9B,IAEET,aAAa,IAAIS,IAAI,KAAK,MAH7B;AAIA,YAAMG,MAAM,GAAGD,cAAc,GAAG,CAAH,GAAO,CAApC,CATsE,CAWtE;;AACAT,MAAAA,iBAAiB,GAAGM,QAApB;AACAP,MAAAA,cAAc,GAAGI,KAAK,GAAGO,MAAzB;AACA;AACD,GAvBD;AAyBA,SAAOX,cAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,S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B;AAClBZ,MAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA;;AAlBkB,GAAb,CAAP;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of block DOM elements finds the index that a block should be dropped\n * at.\n *\n * @param {Element[]} elements Array of DOM elements that represent each block in a block list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex( elements, position, orientation ) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\telements.forEach( ( element, index ) => {\n\t\tconst rect = element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\n\treturn candidateIndex;\n}\n\n/**\n * Determine if the element is an empty paragraph block.\n *\n * @param {?HTMLElement} element The element being tested.\n * @return {boolean} True or False.\n */\nfunction isEmptyParagraph( element ) {\n\treturn (\n\t\t!! element &&\n\t\telement.dataset.type === 'core/paragraph' &&\n\t\telement.dataset.empty === 'true'\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst [ targetBlockIndex, setTargetBlockIndex ] = useState( null );\n\n\tconst isDisabled = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetTemplateLock,\n\t\t\t\t__unstableIsWithinBlockOverlay,\n\t\t\t\t__unstableHasActiveBlockOverlayActive,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst templateLock = getTemplateLock( targetRootClientId );\n\t\t\treturn (\n\t\t\t\t[ 'all', 'contentOnly' ].some(\n\t\t\t\t\t( lock ) => lock === templateLock\n\t\t\t\t) ||\n\t\t\t\t__unstableHasActiveBlockOverlayActive( targetRootClientId ) ||\n\t\t\t\t__unstableIsWithinBlockOverlay( targetRootClientId )\n\t\t\t);\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings } = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\tconst throttled = useThrottle(\n\t\tuseCallback( ( event, currentTarget ) => {\n\t\t\tconst blockElements = Array.from( currentTarget.children ).filter(\n\t\t\t\t// Ensure the element is a block. It should have the `wp-block` class.\n\t\t\t\t( element ) => element.classList.contains( 'wp-block' )\n\t\t\t);\n\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\tblockElements,\n\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t);\n\n\t\t\tsetTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );\n\n\t\t\tif ( targetIndex !== undefined ) {\n\t\t\t\tconst nextBlock = blockElements[ targetIndex ];\n\t\t\t\tconst previousBlock = blockElements[ targetIndex - 1 ];\n\n\t\t\t\t// Don't show the insertion point when it's near an empty paragraph block.\n\t\t\t\tif (\n\t\t\t\t\tisEmptyParagraph( nextBlock ) ||\n\t\t\t\t\tisEmptyParagraph( previousBlock )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex );\n\t\t\t}\n\t\t}, [] ),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t} );\n}\n"]}
|