@wordpress/block-editor 8.5.2 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +82 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +67 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +63 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +111 -246
- package/build-style/style.css +111 -246
- package/package.json +28 -28
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +14 -2
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +12 -3
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/style.scss +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"names":["InsertionPointOpenRef","InsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","selectBlock","hideInsertionPoint","blockEditorStore","openRef","ref","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","insertionPoint","order","length","_previousClientId","index","_nextClientId","__unstableWithInserter","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","offsetWidth","height","top","bottom","left","right","offsetHeight","getAnchorRect","ownerDocument","popoverScrollRef","disableMotion","className","onClick","event","target","current","onFocus","maybeHideInserterPoint","showInsertionPointInserter","horizontalLine","start","x","rest","hover","verticalLine","y","lineVariants","opacity","borderRadius","transition","delay","inserterVariants","scale","isOpen","InsertionPoint","children","isVisible","isBlockInsertionPointVisible"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAMO,MAAMA,qBAAqB,GAAG,6BAA9B;;;AAEP,SAASC,qBAAT,OAGI;A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xD,YAFZ;AAGC,IAAA,YAAY,EAAGC,YAHhB;AAIC,IAAA,qBAAqB,MAJtB;AAKC,IAAA,QAAQ,EAAKyD,MAAF,IAAc;AACxB9D,MAAAA,OAAO,CAAC4C,OAAR,GAAkBkB,MAAlB;AACA,KAPF;AAQC,IAAA,eAAe,EAAG,MAAM;AACvB9D,MAAAA,OAAO,CAAC4C,OAAR,GAAkB,KAAlB;AACA;AAVF,IAND,CAtBF,CAdD,CADD;AA4DA;AACA;;AAEc,SAASmB,cAAT,QAIX;AAAA,MAJoC;AACvCC,IAAAA,QADuC;AAEvCrE,IAAAA,qBAFuC;AAGvCC,IAAAA;AAHuC,GAIpC;AACH,QAAMqE,SAAS,GAAG,qBAAa1D,MAAF,IAAc;AAC1C,WAAOA,MAAM,CAAER,YAAF,CAAN,CAA2BmE,4BAA3B,EAAP;AACA,GAFiB,EAEf,EAFe,CAAlB;AAIA,SACC,4BAAC,qBAAD,CAAuB,QAAvB;AAAgC,IAAA,KAAK,EAAG,qBAAQ,KAAR;AAAxC,KACGD,SAAS,IACV,4BAAC,qBAAD;AACC,IAAA,qBAAqB,EAAGtE,qBADzB;AAEC,IAAA,oBAAoB,EAAGC;AAFxB,IAFF,EAOGoE,QAPH,CADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseRef,\n\tuseMemo,\n\tcreateContext,\n\tuseContext,\n} from '@wordpress/element';\nimport { Popover, __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { usePopoverScroll } from './use-popover-scroll';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\tconst style = useMemo( () => {\n\t\tif ( ! previousElement && ! nextElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousElement\n\t\t\t\t\t? previousElement.offsetWidth\n\t\t\t\t\t: nextElement.offsetWidth,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousElement\n\t\t\t\t? previousElement.offsetHeight\n\t\t\t\t: nextElement.offsetHeight,\n\t\t};\n\t}, [ previousElement, nextElement ] );\n\n\tconst getAnchorRect = useCallback( () => {\n\t\tif ( ! previousElement && ! nextElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\tif ( isRTL() ) {\n\t\t\t\treturn {\n\t\t\t\t\ttop: previousRect ? previousRect.bottom : nextRect.top,\n\t\t\t\t\tleft: previousRect ? previousRect.right : nextRect.right,\n\t\t\t\t\tright: previousRect ? previousRect.left : nextRect.left,\n\t\t\t\t\tbottom: nextRect ? nextRect.top : previousRect.bottom,\n\t\t\t\t\townerDocument,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttop: previousRect ? previousRect.bottom : nextRect.top,\n\t\t\t\tleft: previousRect ? previousRect.left : nextRect.left,\n\t\t\t\tright: previousRect ? previousRect.right : nextRect.right,\n\t\t\t\tbottom: nextRect ? nextRect.top : previousRect.bottom,\n\t\t\t\townerDocument,\n\t\t\t};\n\t\t}\n\n\t\tif ( isRTL() ) {\n\t\t\treturn {\n\t\t\t\ttop: previousRect ? previousRect.top : nextRect.top,\n\t\t\t\tleft: previousRect ? previousRect.left : nextRect.right,\n\t\t\t\tright: nextRect ? nextRect.right : previousRect.left,\n\t\t\t\tbottom: previousRect ? previousRect.bottom : nextRect.bottom,\n\t\t\t\townerDocument,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\ttop: previousRect ? previousRect.top : nextRect.top,\n\t\t\tleft: previousRect ? previousRect.right : nextRect.left,\n\t\t\tright: nextRect ? nextRect.left : previousRect.right,\n\t\t\tbottom: previousRect ? previousRect.bottom : nextRect.bottom,\n\t\t\townerDocument,\n\t\t};\n\t}, [ previousElement, nextElement ] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\tconst disableMotion = useReducedMotion();\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\t'is-' + orientation\n\t);\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\t// Only show the in-between inserter between blocks, so when there's a\n\t// previous and a next element.\n\tconst showInsertionPointInserter =\n\t\tpreviousElement && nextElement && isInserterShown;\n\n\t// Define animation variants for the line element.\n\tconst horizontalLine = {\n\t\tstart: {\n\t\t\twidth: 0,\n\t\t\ttop: '50%',\n\t\t\tbottom: '50%',\n\t\t\tx: 0,\n\t\t},\n\t\trest: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t\thover: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t};\n\tconst verticalLine = {\n\t\tstart: {\n\t\t\theight: 0,\n\t\t\tleft: '50%',\n\t\t\tright: '50%',\n\t\t\ty: 0,\n\t\t},\n\t\trest: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t\thover: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t};\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\t...( ! isVertical ? horizontalLine.start : verticalLine.start ),\n\t\t\topacity: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\t...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: showInsertionPointInserter ? 0.4 : 0 },\n\t\t},\n\t\thover: {\n\t\t\t...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: 0.4 },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.2 },\n\t\t},\n\t};\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tnoArrow\n\t\t\tanimate={ false }\n\t\t\tgetAnchorRect={ getAnchorRect }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-block-list__insertion-point-popover\"\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 the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': showInsertionPointInserter,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ showInsertionPointInserter && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default function InsertionPoint( {\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst isVisible = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isBlockInsertionPointVisible();\n\t}, [] );\n\n\treturn (\n\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t{ isVisible && (\n\t\t\t\t<InsertionPointPopover\n\t\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ children }\n\t\t</InsertionPointOpenRef.Provider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"names":["InsertionPointOpenRef","InsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","selectBlock","hideInsertionPoint","blockEditorStore","openRef","ref","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","insertionPoint","order","length","_previousClientId","index","_nextClientId","__unstableWithInserter","isVertical","disableMotion","onClick","event","target","current","onFocus","maybeHideInserterPoint","horizontalLine","start","width","top","bottom","x","rest","hover","verticalLine","height","left","right","y","lineVariants","opacity","borderRadius","transition","delay","inserterVariants","scale","className","isOpen","InsertionPoint","children","props","isVisible","isBlockInsertionPointVisible"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAKO,MAAMA,qBAAqB,GAAG,6BAA9B;;;AAEP,SAASC,qBAAT,OAGI;AAAA,MAH4B;AAC/BC,IAAAA,qBAD+B;AAE/BC,IAAAA;AAF+B,GAG5B;AACH,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAsC,uBAAaC,YAAb,CAA5C;AACA,QAAMC,OAAO,GAAG,yBAAYP,qBAAZ,CAAhB;AACA,QAAMQ,GAAG,GAAG,sBAAZ;AACA,QAAM;AACLC,IAAAA,WADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,YAJK;AAKLC,IAAAA;AALK,MAMF,qBAAaC,MAAF,IAAc;AAAA;;AAC5B,UAAM;AACLC,MAAAA,aADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,sBAHK;AAILC,MAAAA,mBAJK;AAKLC,MAAAA,wBALK;AAMLC,MAAAA;AANK,QAOFN,MAAM,CAAER,YAAF,CAPV;AAQA,UAAMe,cAAc,GAAGJ,sBAAsB,EAA7C;AACA,UAAMK,KAAK,GAAGP,aAAa,CAAEM,cAAc,CAACT,YAAjB,CAA3B;;AAEA,QAAK,CAAEU,KAAK,CAACC,MAAb,EAAsB;AACrB,aAAO,EAAP;AACA;;AAED,QAAIC,iBAAiB,GAAGF,KAAK,CAAED,cAAc,CAACI,KAAf,GAAuB,CAAzB,CAA7B;AACA,QAAIC,aAAa,GAAGJ,KAAK,CAAED,cAAc,CAACI,KAAjB,CAAzB;;AAEA,WAAQP,mBAAmB,CAAEM,iBAAF,CAA3B,EAAmD;AAClDA,MAAAA,iBAAiB,GAAGL,wBAAwB,C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n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, createContext, useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverInbetween from '../block-popover/inbetween';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst disableMotion = useReducedMotion();\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\t// Define animation variants for the line element.\n\tconst horizontalLine = {\n\t\tstart: {\n\t\t\twidth: 0,\n\t\t\ttop: '50%',\n\t\t\tbottom: '50%',\n\t\t\tx: 0,\n\t\t},\n\t\trest: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t\thover: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t};\n\tconst verticalLine = {\n\t\tstart: {\n\t\t\theight: 0,\n\t\t\tleft: '50%',\n\t\t\tright: '50%',\n\t\t\ty: 0,\n\t\t},\n\t\trest: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t\thover: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t};\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\t...( ! isVertical ? horizontalLine.start : verticalLine.start ),\n\t\t\topacity: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\t...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: isInserterShown ? 0.4 : 0 },\n\t\t},\n\t\thover: {\n\t\t\t...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: 0.4 },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.2 },\n\t\t},\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\t'is-' + orientation\n\t);\n\n\treturn (\n\t\t<BlockPopoverInbetween\n\t\t\tpreviousClientId={ previousClientId }\n\t\t\tnextClientId={ nextClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': isInserterShown,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ isInserterShown && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</BlockPopoverInbetween>\n\t);\n}\n\nexport default function InsertionPoint( { children, ...props } ) {\n\tconst isVisible = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isBlockInsertionPointVisible();\n\t}, [] );\n\n\treturn (\n\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t{ isVisible && <InsertionPointPopover { ...props } /> }\n\t\t\t{ children }\n\t\t</InsertionPointOpenRef.Provider>\n\t);\n}\n"]}
|
|
@@ -15,16 +15,12 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
15
15
|
|
|
16
16
|
var _blocks = require("@wordpress/blocks");
|
|
17
17
|
|
|
18
|
-
var _components = require("@wordpress/components");
|
|
19
|
-
|
|
20
18
|
var _data = require("@wordpress/data");
|
|
21
19
|
|
|
22
20
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
23
21
|
|
|
24
22
|
var _compose = require("@wordpress/compose");
|
|
25
23
|
|
|
26
|
-
var _dom = require("@wordpress/dom");
|
|
27
|
-
|
|
28
24
|
var _blockSelectionButton = _interopRequireDefault(require("./block-selection-button"));
|
|
29
25
|
|
|
30
26
|
var _blockContextualToolbar = _interopRequireDefault(require("./block-contextual-toolbar"));
|
|
@@ -33,9 +29,7 @@ var _inserter = _interopRequireDefault(require("../inserter"));
|
|
|
33
29
|
|
|
34
30
|
var _store = require("../../store");
|
|
35
31
|
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _usePopoverScroll = require("./use-popover-scroll");
|
|
32
|
+
var _blockPopover = _interopRequireDefault(require("../block-popover"));
|
|
39
33
|
|
|
40
34
|
/**
|
|
41
35
|
* External dependencies
|
|
@@ -54,7 +48,6 @@ function selector(select) {
|
|
|
54
48
|
isMultiSelecting,
|
|
55
49
|
hasMultiSelection,
|
|
56
50
|
isTyping,
|
|
57
|
-
isCaretWithinFormattedText,
|
|
58
51
|
getSettings,
|
|
59
52
|
getLastMultiSelectedBlockClientId
|
|
60
53
|
} = select(_store.store);
|
|
@@ -62,18 +55,15 @@ function selector(select) {
|
|
|
62
55
|
isNavigationMode: isNavigationMode(),
|
|
63
56
|
isMultiSelecting: isMultiSelecting(),
|
|
64
57
|
isTyping: isTyping(),
|
|
65
|
-
isCaretWithinFormattedText: isCaretWithinFormattedText(),
|
|
66
|
-
hasMultiSelection: hasMultiSelection(),
|
|
67
58
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
68
|
-
lastClientId: getLastMultiSelectedBlockClientId()
|
|
59
|
+
lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
|
|
69
60
|
};
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
function
|
|
63
|
+
function SelectedBlockPopover(_ref) {
|
|
73
64
|
let {
|
|
74
65
|
clientId,
|
|
75
66
|
rootClientId,
|
|
76
|
-
isValid,
|
|
77
67
|
isEmptyDefaultBlock,
|
|
78
68
|
capturingClientId,
|
|
79
69
|
__unstablePopoverSlot,
|
|
@@ -83,8 +73,6 @@ function BlockPopover(_ref) {
|
|
|
83
73
|
isNavigationMode,
|
|
84
74
|
isMultiSelecting,
|
|
85
75
|
isTyping,
|
|
86
|
-
isCaretWithinFormattedText,
|
|
87
|
-
hasMultiSelection,
|
|
88
76
|
hasFixedToolbar,
|
|
89
77
|
lastClientId
|
|
90
78
|
} = (0, _data.useSelect)(selector, []);
|
|
@@ -104,108 +92,49 @@ function BlockPopover(_ref) {
|
|
|
104
92
|
return order[insertionPoint.index] === clientId;
|
|
105
93
|
}, [clientId]);
|
|
106
94
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
107
|
-
const
|
|
95
|
+
const isToolbarForced = (0, _element.useRef)(false);
|
|
108
96
|
const [isInserterShown, setIsInserterShown] = (0, _element.useState)(false);
|
|
109
97
|
const {
|
|
110
98
|
stopTyping
|
|
111
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
|
|
99
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
100
|
+
const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock;
|
|
115
101
|
const shouldShowBreadcrumb = isNavigationMode;
|
|
116
|
-
const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !
|
|
102
|
+
const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping;
|
|
117
103
|
const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
|
|
118
104
|
(0, _keyboardShortcuts.useShortcut)('core/block-editor/focus-toolbar', () => {
|
|
119
|
-
|
|
105
|
+
isToolbarForced.current = true;
|
|
120
106
|
stopTyping(true);
|
|
121
107
|
}, {
|
|
122
108
|
isDisabled: !canFocusHiddenToolbar
|
|
123
109
|
});
|
|
124
110
|
(0, _element.useEffect)(() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
|
|
111
|
+
isToolbarForced.current = false;
|
|
112
|
+
}); // Stores the active toolbar item index so the block toolbar can return focus
|
|
129
113
|
// to it when re-mounting.
|
|
130
114
|
|
|
131
115
|
const initialToolbarItemIndexRef = (0, _element.useRef)();
|
|
132
|
-
const selectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
|
|
133
|
-
const lastSelectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(lastClientId);
|
|
134
|
-
const capturingElement = (0, _useBlockRefs.__unstableUseBlockElement)(capturingClientId);
|
|
135
|
-
const popoverScrollRef = (0, _usePopoverScroll.usePopoverScroll)(__unstableContentRef);
|
|
136
116
|
|
|
137
|
-
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar
|
|
117
|
+
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
|
|
138
118
|
return null;
|
|
139
119
|
}
|
|
140
120
|
|
|
141
|
-
let node = selectedElement;
|
|
142
|
-
|
|
143
|
-
if (!node) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (capturingClientId) {
|
|
148
|
-
node = capturingElement;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
let anchorRef = node;
|
|
152
|
-
|
|
153
|
-
if (hasMultiSelection) {
|
|
154
|
-
// Wait to render the popover until the bottom reference is available
|
|
155
|
-
// as well.
|
|
156
|
-
if (!lastSelectedElement) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
anchorRef = {
|
|
161
|
-
top: node,
|
|
162
|
-
bottom: lastSelectedElement
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
121
|
function onFocus() {
|
|
167
122
|
setIsInserterShown(true);
|
|
168
123
|
}
|
|
169
124
|
|
|
170
125
|
function onBlur() {
|
|
171
126
|
setIsInserterShown(false);
|
|
172
|
-
}
|
|
173
|
-
// left corner. For the side inserter, pop out towards the left, and
|
|
174
|
-
// position in the right corner.
|
|
175
|
-
// To do: refactor `Popover` to make this prop clearer.
|
|
176
|
-
|
|
127
|
+
}
|
|
177
128
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
} = node;
|
|
182
|
-
const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
|
|
183
|
-
// the block toolbar becomes sticky when the block scolls out of view.
|
|
184
|
-
// In case of an iframe, this should be the iframe boundary, otherwise
|
|
185
|
-
// the scroll container.
|
|
186
|
-
ownerDocument.defaultView.frameElement || (0, _dom.getScrollContainer)(node) || ownerDocument.body;
|
|
187
|
-
return (0, _element.createElement)(_components.Popover, {
|
|
188
|
-
ref: popoverScrollRef,
|
|
189
|
-
noArrow: true,
|
|
190
|
-
animate: false,
|
|
191
|
-
position: popoverPosition,
|
|
192
|
-
focusOnMount: false,
|
|
193
|
-
anchorRef: anchorRef,
|
|
129
|
+
return (0, _element.createElement)(_blockPopover.default, {
|
|
130
|
+
clientId: capturingClientId || clientId,
|
|
131
|
+
bottomClientId: lastClientId,
|
|
194
132
|
className: (0, _classnames.default)('block-editor-block-list__block-popover', {
|
|
195
133
|
'is-insertion-point-visible': isInsertionPointVisible
|
|
196
134
|
}),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
__unstableSlotName: __unstablePopoverSlot || null,
|
|
201
|
-
__unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
|
|
202
|
-
,
|
|
203
|
-
__unstableObserveElement: node,
|
|
204
|
-
shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently
|
|
205
|
-
// obscure specific sections of a block.
|
|
206
|
-
,
|
|
207
|
-
__unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current
|
|
208
|
-
}, (shouldShowContextualToolbar || isToolbarForced) && (0, _element.createElement)("div", {
|
|
135
|
+
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
136
|
+
__unstableContentRef: __unstableContentRef
|
|
137
|
+
}, shouldShowContextualToolbar && (0, _element.createElement)("div", {
|
|
209
138
|
onFocus: onFocus,
|
|
210
139
|
onBlur: onBlur // While ideally it would be enough to capture the
|
|
211
140
|
// bubbling focus event from the Inserter, due to the
|
|
@@ -222,10 +151,10 @@ function BlockPopover(_ref) {
|
|
|
222
151
|
clientId: clientId,
|
|
223
152
|
rootClientId: rootClientId,
|
|
224
153
|
__experimentalIsQuick: true
|
|
225
|
-
})),
|
|
154
|
+
})), shouldShowContextualToolbar && (0, _element.createElement)(_blockContextualToolbar.default // If the toolbar is being shown because of being forced
|
|
226
155
|
// it should focus the toolbar right after the mount.
|
|
227
156
|
, {
|
|
228
|
-
focusOnMount: isToolbarForced,
|
|
157
|
+
focusOnMount: isToolbarForced.current,
|
|
229
158
|
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
230
159
|
__experimentalOnIndexChange: index => {
|
|
231
160
|
initialToolbarItemIndexRef.current = index;
|
|
@@ -235,16 +164,8 @@ function BlockPopover(_ref) {
|
|
|
235
164
|
key: clientId
|
|
236
165
|
}), shouldShowBreadcrumb && (0, _element.createElement)(_blockSelectionButton.default, {
|
|
237
166
|
clientId: clientId,
|
|
238
|
-
rootClientId: rootClientId
|
|
239
|
-
|
|
240
|
-
}), showEmptyBlockSideInserter && (0, _element.createElement)("div", {
|
|
241
|
-
className: "block-editor-block-list__empty-block-inserter"
|
|
242
|
-
}, (0, _element.createElement)(_inserter.default, {
|
|
243
|
-
position: "bottom right",
|
|
244
|
-
rootClientId: rootClientId,
|
|
245
|
-
clientId: clientId,
|
|
246
|
-
__experimentalIsQuick: true
|
|
247
|
-
})));
|
|
167
|
+
rootClientId: rootClientId
|
|
168
|
+
}));
|
|
248
169
|
}
|
|
249
170
|
|
|
250
171
|
function wrapperSelector(select) {
|
|
@@ -264,8 +185,7 @@ function wrapperSelector(select) {
|
|
|
264
185
|
|
|
265
186
|
const {
|
|
266
187
|
name,
|
|
267
|
-
attributes = {}
|
|
268
|
-
isValid
|
|
188
|
+
attributes = {}
|
|
269
189
|
} = getBlock(clientId) || {};
|
|
270
190
|
const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId.
|
|
271
191
|
|
|
@@ -281,7 +201,6 @@ function wrapperSelector(select) {
|
|
|
281
201
|
clientId,
|
|
282
202
|
rootClientId: getBlockRootClientId(clientId),
|
|
283
203
|
name,
|
|
284
|
-
isValid,
|
|
285
204
|
isEmptyDefaultBlock: name && (0, _blocks.isUnmodifiedDefaultBlock)({
|
|
286
205
|
name,
|
|
287
206
|
attributes
|
|
@@ -305,7 +224,6 @@ function WrappedBlockPopover(_ref2) {
|
|
|
305
224
|
clientId,
|
|
306
225
|
rootClientId,
|
|
307
226
|
name,
|
|
308
|
-
isValid,
|
|
309
227
|
isEmptyDefaultBlock,
|
|
310
228
|
capturingClientId
|
|
311
229
|
} = selected;
|
|
@@ -314,14 +232,13 @@ function WrappedBlockPopover(_ref2) {
|
|
|
314
232
|
return null;
|
|
315
233
|
}
|
|
316
234
|
|
|
317
|
-
return (0, _element.createElement)(
|
|
235
|
+
return (0, _element.createElement)(SelectedBlockPopover, {
|
|
318
236
|
clientId: clientId,
|
|
319
237
|
rootClientId: rootClientId,
|
|
320
|
-
isValid: isValid,
|
|
321
238
|
isEmptyDefaultBlock: isEmptyDefaultBlock,
|
|
322
239
|
capturingClientId: capturingClientId,
|
|
323
240
|
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
324
241
|
__unstableContentRef: __unstableContentRef
|
|
325
242
|
});
|
|
326
243
|
}
|
|
327
|
-
//# sourceMappingURL=block-popover.js.map
|
|
244
|
+
//# sourceMappingURL=selected-block-popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","isInserterShown","setIsInserterShown","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","onFocus","onBlur","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAOA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,SAAO;AACNN,IAAAA,gBAAgB,EAAEA,gBAAgB,EAD5B;AAENC,IAAAA,gBAAgB,EAAEA,gBAAgB,EAF5B;AAGNE,IAAAA,QAAQ,EAAEA,QAAQ,EAHZ;AAINI,IAAAA,eAAe,EAAEH,WAAW,GAAGG,eAJzB;AAKNC,IAAAA,YAAY,EAAEN,iBAAiB,KAC5BG,iCAAiC,EADL,GAE5B;AAPG,GAAP;AASA;;AAED,SAASI,oBAAT,OAOI;AAAA,MAP2B;AAC9BC,IAAAA,QAD8B;AAE9BC,IAAAA,YAF8B;AAG9BC,IAAAA,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,IAAAA,mBAAmB,EAClBgC,IAAI,IAAI,sCAA0B;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CALH;AAMNhC,IAAAA;AANM,GAAP;AAQA;;AAEc,SAASqC,mBAAT,QAGX;AAAA,MAHyC;AAC5CpC,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMoC,QAAQ,GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLzC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGLiC,IAAAA,IAHK;AAILhC,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFsC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGlC,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst [ isInserterShown, setIsInserterShown ] = useState( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\tfunction onFocus() {\n\t\tsetIsInserterShown( true );\n\t}\n\n\tfunction onBlur() {\n\t\tsetIsInserterShown( false );\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<div\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t// While ideally it would be enough to capture the\n\t\t\t\t\t// bubbling focus event from the Inserter, due to the\n\t\t\t\t\t// characteristics of click focusing of `button`s in\n\t\t\t\t\t// Firefox and Safari, it is not reliable.\n\t\t\t\t\t//\n\t\t\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-popover-inserter',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-visible': isInserterShown,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -13,6 +13,8 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
|
|
14
14
|
var _keycodes = require("@wordpress/keycodes");
|
|
15
15
|
|
|
16
|
+
var _icons = require("@wordpress/icons");
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* WordPress dependencies
|
|
18
20
|
*/
|
|
@@ -51,8 +53,10 @@ function DuotoneControl(_ref) {
|
|
|
51
53
|
"aria-expanded": isOpen,
|
|
52
54
|
onKeyDown: openOnArrowDown,
|
|
53
55
|
label: (0, _i18n.__)('Apply duotone filter'),
|
|
54
|
-
icon: (0, _element.createElement)(_components.DuotoneSwatch, {
|
|
56
|
+
icon: value ? (0, _element.createElement)(_components.DuotoneSwatch, {
|
|
55
57
|
values: value
|
|
58
|
+
}) : (0, _element.createElement)(_icons.Icon, {
|
|
59
|
+
icon: _icons.filter
|
|
56
60
|
})
|
|
57
61
|
});
|
|
58
62
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/duotone-control/index.js"],"names":["DuotoneControl","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","className","headerTitle","isAlternate","isOpen","onToggle","openOnArrowDown","event","keyCode","DOWN","preventDefault"],"mappings":";;;;;;;;;AAGA;;AAOA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/duotone-control/index.js"],"names":["DuotoneControl","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","className","headerTitle","isAlternate","isOpen","onToggle","openOnArrowDown","event","keyCode","DOWN","preventDefault","filter"],"mappings":";;;;;;;;;AAGA;;AAOA;;AACA;;AACA;;AAZA;AACA;AACA;AAYA,SAASA,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,YADwB;AAExBC,IAAAA,cAFwB;AAGxBC,IAAAA,mBAHwB;AAIxBC,IAAAA,oBAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA;AANwB,GAOrB;AACH,SACC,4BAAC,oBAAD;AACC,IAAA,YAAY,EAAG;AACdC,MAAAA,SAAS,EAAE,uCADG;AAEdC,MAAAA,WAAW,EAAE,cAAI,SAAJ,CAFC;AAGdC,MAAAA,WAAW,EAAE;AAHC,KADhB;AAMC,IAAA,YAAY,EAAG,SAA4B;AAAA,UAA1B;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAA0B;;AAC1C,YAAMC,eAAe,GAAKC,KAAF,IAAa;AACpC,YAAK,CAAEH,MAAF,IAAYG,KAAK,CAACC,OAAN,KAAkBC,cAAnC,EAA0C;AACzCF,UAAAA,KAAK,CAACG,cAAN;AACAL,UAAAA,QAAQ;AACR;AACD,OALD;;AAMA,aACC,4BAAC,yBAAD;AACC,QAAA,WAAW,MADZ;AAEC,QAAA,OAAO,EAAGA,QAFX;AAGC,yBAAc,MAHf;AAIC,yBAAgBD,MAJjB;AAKC,QAAA,SAAS,EAAGE,eALb;AAMC,QAAA,KAAK,EAAG,cAAI,sBAAJ,CANT;AAOC,QAAA,IAAI,EACHP,KAAK,GACJ,4BAAC,yBAAD;AAAe,UAAA,MAAM,EAAGA;AAAxB,UADI,GAGJ,4BAAC,WAAD;AAAM,UAAA,IAAI,EAAGY;AAAb;AAXH,QADD;AAiBA,KA9BF;AA+BC,IAAA,aAAa,EAAG,MACf,4BAAC,qBAAD;AAAW,MAAA,KAAK,EAAG,cAAI,SAAJ;AAAnB,OACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACG,cACD,oEADC,CADH,CADD,EAMC,4BAAC,yBAAD;AACC,MAAA,YAAY,EAAGhB,YADhB;AAEC,MAAA,cAAc,EAAGC,cAFlB;AAGC,MAAA,mBAAmB,EAAGC,mBAHvB;AAIC,MAAA,oBAAoB,EAAGC,oBAJxB;AAKC,MAAA,KAAK,EAAGC,KALT;AAMC,MAAA,QAAQ,EAAGC;AANZ,MAND;AAhCF,IADD;AAmDA;;eAEcN,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tMenuGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport { Icon, filter } from '@wordpress/icons';\n\nfunction DuotoneControl( {\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ {\n\t\t\t\tclassName: 'block-editor-duotone-control__popover',\n\t\t\t\theaderTitle: __( 'Duotone' ),\n\t\t\t\tisAlternate: true,\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ __( 'Apply duotone filter' ) }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tvalue ? (\n\t\t\t\t\t\t\t\t<DuotoneSwatch values={ value } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ filter } />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t<div className=\"block-editor-duotone-control__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default DuotoneControl;\n"]}
|
|
@@ -9,6 +9,8 @@ exports.default = exports.Inserter = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _reactNative = require("react-native");
|
|
13
15
|
|
|
14
16
|
var _lodash = require("lodash");
|
|
@@ -53,14 +55,30 @@ const defaultRenderToggle = _ref => {
|
|
|
53
55
|
onToggle,
|
|
54
56
|
disabled,
|
|
55
57
|
style,
|
|
56
|
-
|
|
58
|
+
containerStyle,
|
|
59
|
+
onLongPress,
|
|
60
|
+
useExpandedMode
|
|
57
61
|
} = _ref;
|
|
58
|
-
|
|
62
|
+
// The "expanded mode" refers to the editor's appearance when no blocks
|
|
63
|
+
// are currently selected. The "add block" button has a separate style
|
|
64
|
+
// for the "expanded mode", which are added via the below "expandedModeViewProps"
|
|
65
|
+
// and "expandedModeViewText" variables.
|
|
66
|
+
const expandedModeViewProps = useExpandedMode && {
|
|
67
|
+
icon: (0, _element.createElement)(_icons.Icon, {
|
|
68
|
+
icon: _icons.plus,
|
|
69
|
+
style: style
|
|
70
|
+
}),
|
|
71
|
+
customContainerStyles: containerStyle,
|
|
72
|
+
fixedRatio: false
|
|
73
|
+
};
|
|
74
|
+
const expandedModeViewText = (0, _element.createElement)(_reactNative.Text, {
|
|
75
|
+
style: _style.default['inserter-menu__add-block-button-text']
|
|
76
|
+
}, (0, _i18n.__)('Add Blocks'));
|
|
77
|
+
return (0, _element.createElement)(_components.ToolbarButton, (0, _extends2.default)({
|
|
59
78
|
title: (0, _i18n._x)('Add block', 'Generic label for block inserter button'),
|
|
60
79
|
icon: (0, _element.createElement)(_icons.Icon, {
|
|
61
80
|
icon: _icons.plusCircleFilled,
|
|
62
|
-
style: style
|
|
63
|
-
color: style.color
|
|
81
|
+
style: style
|
|
64
82
|
}),
|
|
65
83
|
onClick: onToggle,
|
|
66
84
|
extraProps: {
|
|
@@ -71,7 +89,7 @@ const defaultRenderToggle = _ref => {
|
|
|
71
89
|
onLongPress
|
|
72
90
|
},
|
|
73
91
|
isDisabled: disabled
|
|
74
|
-
});
|
|
92
|
+
}, expandedModeViewProps), useExpandedMode && expandedModeViewText);
|
|
75
93
|
};
|
|
76
94
|
|
|
77
95
|
class Inserter extends _element.Component {
|
|
@@ -232,14 +250,16 @@ class Inserter extends _element.Component {
|
|
|
232
250
|
disabled,
|
|
233
251
|
renderToggle = defaultRenderToggle,
|
|
234
252
|
getStylesFromColorScheme,
|
|
235
|
-
showSeparator
|
|
253
|
+
showSeparator,
|
|
254
|
+
useExpandedMode
|
|
236
255
|
} = this.props;
|
|
237
256
|
|
|
238
257
|
if (showSeparator && isOpen) {
|
|
239
258
|
return (0, _element.createElement)(_insertionPoint.default, null);
|
|
240
259
|
}
|
|
241
260
|
|
|
242
|
-
const style = getStylesFromColorScheme(_style.default
|
|
261
|
+
const style = useExpandedMode ? _style.default['inserter-menu__add-block-button-icon--expanded'] : getStylesFromColorScheme(_style.default['inserter-menu__add-block-button-icon'], _style.default['inserter-menu__add-block-button-icon--dark']);
|
|
262
|
+
const containerStyle = getStylesFromColorScheme(_style.default['inserter-menu__add-block-button'], _style.default['inserter-menu__add-block-button--dark']);
|
|
243
263
|
|
|
244
264
|
const onPress = () => {
|
|
245
265
|
this.setState({
|
|
@@ -268,7 +288,9 @@ class Inserter extends _element.Component {
|
|
|
268
288
|
isOpen,
|
|
269
289
|
disabled,
|
|
270
290
|
style,
|
|
271
|
-
|
|
291
|
+
containerStyle,
|
|
292
|
+
onLongPress,
|
|
293
|
+
useExpandedMode
|
|
272
294
|
}), (0, _element.createElement)(_components.Picker, {
|
|
273
295
|
ref: instance => this.picker = instance,
|
|
274
296
|
options: this.getInsertionOptions(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.native.js"],"names":["VOICE_OVER_ANNOUNCEMENT_DELAY","defaultRenderToggle","onToggle","disabled","style","onLongPress","plusCircleFilled","color","hint","testID","Inserter","Component","constructor","arguments","bind","renderInserterToggle","renderContent","getInsertionOptions","addBeforeOption","value","label","icon","plusCircle","replaceCurrentOption","addAfterOption","addToBeginningOption","insertBefore","addToEndOption","insertAfter","isAnyBlockSelected","isSelectedBlockReplaceable","props","getInsertionIndex","insertionType","insertionIndexDefault","insertionIndexStart","insertionIndexBefore","insertionIndexAfter","insertionIndexEnd","shouldReplaceBlock","isOpen","blockTypeImpressions","updateSettings","impressionsRemain","Object","values","some","count","decrementedImpressions","entries","reduce","acc","blockName","Math","max","impressions","onInserterToggledAnnouncement","AccessibilityInfo","isScreenReaderEnabled","done","isEnabled","isIOS","Platform","OS","announcement","announceForAccessibility","renderToggle","getStylesFromColorScheme","showSeparator","styles","addBlockButton","addBlockButtonDark","onPress","setState","destinationRootClientId","insertionIndex","picker","presentPicker","onPickerSelect","instance","onClose","clientId","isAppender","state","render","dispatch","blockEditorStore","select","rootClientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","getBlock","getSettings","getBlockEditorSettings","end","selectedBlockIndex","endOfRootIndex","length","isSelectedUnmodifiedDefaultBlock","undefined","getDefaultInsertionIndex","__experimentalShouldInsertAtTheTop","shouldInsertAtTheTop","withPreferredColorScheme"],"mappings":";;;;;;;;;AAWA;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;AAMA,MAAMA,6BAA6B,GAAG,IAAtC;;AAEA,MAAMC,mBAAmB,GAAG;AAAA,MAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,KAAtB;AAA6BC,IAAAA;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BAAL,EAA4B;AAC3B,aAAO,CAAP;AACA,KARkC,CAUnC;;;AACA,QAAKvB,QAAL,EAAgB;AACf,aAAOW,aAAa,CAAEX,QAAF,CAApB;AACA,KAbkC,CAenC;;;AACA,QAAKpD,kBAAL,EAA0B;AACzB;AACA,UAAKuE,gCAAL,EAAwC;AACvC,eAAOH,kBAAP;AACA,OAJwB,CAMzB;;;AACA,aAAOA,kBAAkB,GAAG,CAA5B;AACA,KAxBkC,CA0BnC;;;AACA,WAAOC,cAAP;AACA;;AAED,QAAM/D,mBAAmB,GAAG,CAA5B;AAEA,QAAMC,oBAAoB,GAAGP,kBAAkB,GAC5CoE,kBAD4C,GAE5C9D,mBAFH;AAIA,QAAME,mBAAmB,GAAGR,kBAAkB,GAC3CoE,kBAAkB,GAAG,CADsB,GAE3CC,cAFH;AAIA,QAAM5D,iBAAiB,GAAG4D,cAA1B;AAEA,SAAO;AACNzD,IAAAA,oBAAoB,EAAEsD,sBAAsB,GAAGxC,WADzC;AAENmB,IAAAA,uBAFM;AAGNxC,IAAAA,qBAAqB,EAAEoE,wBAAwB,EAHzC;AAINlE,IAAAA,oBAJM;AAKNC,IAAAA,mBALM;AAMNF,IAAAA,mBANM;AAONG,IAAAA,iBAPM;AAQNT,IAAAA,kBAAkB,EAAE,CAAC,CAAEA,kBARjB;AASNC,IAAAA,0BAA0B,EAAEsE;AATtB,GAAP;AAWA,CA7ED,CALuB,EAoFvBK,iCApFuB,CAAT,EAqFV/F,QArFU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Platform } from 'react-native';\nimport { delay } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Dropdown, ToolbarButton, Picker } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport {\n\tIcon,\n\tplusCircle,\n\tplusCircleFilled,\n\tinsertAfter,\n\tinsertBefore,\n} from '@wordpress/icons';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport InserterMenu from './menu';\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport { store as blockEditorStore } from '../../store';\n\nconst VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;\n\nconst defaultRenderToggle = ( { onToggle, disabled, style, onLongPress } ) => (\n\t<ToolbarButton\n\t\ttitle={ _x( 'Add block', 'Generic label for block inserter button' ) }\n\t\ticon={\n\t\t\t<Icon\n\t\t\t\ticon={ plusCircleFilled }\n\t\t\t\tstyle={ style }\n\t\t\t\tcolor={ style.color }\n\t\t\t/>\n\t\t}\n\t\tonClick={ onToggle }\n\t\textraProps={ {\n\t\t\thint: __( 'Double tap to add a block' ),\n\t\t\t// testID is present to disambiguate this element for native UI tests. It's not\n\t\t\t// usually required for components. See: https://git.io/JeQ7G.\n\t\t\ttestID: 'add-block-button',\n\t\t\tonLongPress,\n\t\t} }\n\t\tisDisabled={ disabled }\n\t/>\n);\n\nexport class Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderInserterToggle = this.renderInserterToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tgetInsertionOptions() {\n\t\tconst addBeforeOption = {\n\t\t\tvalue: 'before',\n\t\t\tlabel: __( 'Add Block Before' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst replaceCurrentOption = {\n\t\t\tvalue: 'replace',\n\t\t\tlabel: __( 'Replace Current Block' ),\n\t\t\ticon: plusCircleFilled,\n\t\t};\n\n\t\tconst addAfterOption = {\n\t\t\tvalue: 'after',\n\t\t\tlabel: __( 'Add Block After' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst addToBeginningOption = {\n\t\t\tvalue: 'start',\n\t\t\tlabel: __( 'Add To Beginning' ),\n\t\t\ticon: insertBefore,\n\t\t};\n\n\t\tconst addToEndOption = {\n\t\t\tvalue: 'end',\n\t\t\tlabel: __( 'Add To End' ),\n\t\t\ticon: insertAfter,\n\t\t};\n\n\t\tconst { isAnyBlockSelected, isSelectedBlockReplaceable } = this.props;\n\t\tif ( isAnyBlockSelected ) {\n\t\t\tif ( isSelectedBlockReplaceable ) {\n\t\t\t\treturn [\n\t\t\t\t\taddToBeginningOption,\n\t\t\t\t\taddBeforeOption,\n\t\t\t\t\treplaceCurrentOption,\n\t\t\t\t\taddAfterOption,\n\t\t\t\t\taddToEndOption,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\taddToBeginningOption,\n\t\t\t\taddBeforeOption,\n\t\t\t\taddAfterOption,\n\t\t\t\taddToEndOption,\n\t\t\t];\n\t\t}\n\t\treturn [ addToBeginningOption, addToEndOption ];\n\t}\n\n\tgetInsertionIndex( insertionType ) {\n\t\tconst {\n\t\t\tinsertionIndexDefault,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexEnd,\n\t\t} = this.props;\n\t\tif ( insertionType === 'start' ) {\n\t\t\treturn insertionIndexStart;\n\t\t}\n\t\tif ( insertionType === 'before' || insertionType === 'replace' ) {\n\t\t\treturn insertionIndexBefore;\n\t\t}\n\t\tif ( insertionType === 'after' ) {\n\t\t\treturn insertionIndexAfter;\n\t\t}\n\t\tif ( insertionType === 'end' ) {\n\t\t\treturn insertionIndexEnd;\n\t\t}\n\t\treturn insertionIndexDefault;\n\t}\n\n\tshouldReplaceBlock( insertionType ) {\n\t\tconst { isSelectedBlockReplaceable } = this.props;\n\t\tif ( insertionType === 'replace' ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( insertionType === 'default' && isSelectedBlockReplaceable ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { blockTypeImpressions, onToggle, updateSettings } = this.props;\n\n\t\tif ( ! isOpen ) {\n\t\t\tconst impressionsRemain = Object.values(\n\t\t\t\tblockTypeImpressions\n\t\t\t).some( ( count ) => count > 0 );\n\n\t\t\tif ( impressionsRemain ) {\n\t\t\t\tconst decrementedImpressions = Object.entries(\n\t\t\t\t\tblockTypeImpressions\n\t\t\t\t).reduce(\n\t\t\t\t\t( acc, [ blockName, count ] ) => ( {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[ blockName ]: Math.max( count - 1, 0 ),\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\t// Persist block type impression to JavaScript store.\n\t\t\t\tupdateSettings( {\n\t\t\t\t\timpressions: decrementedImpressions,\n\t\t\t\t} );\n\n\t\t\t\t// Persist block type impression count to native app store.\n\t\t\t\tsetBlockTypeImpressions( decrementedImpressions );\n\t\t\t}\n\t\t}\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t\tthis.onInserterToggledAnnouncement( isOpen );\n\t}\n\n\tonInserterToggledAnnouncement( isOpen ) {\n\t\tAccessibilityInfo.isScreenReaderEnabled().done( ( isEnabled ) => {\n\t\t\tif ( isEnabled ) {\n\t\t\t\tconst isIOS = Platform.OS === 'ios';\n\t\t\t\tconst announcement = isOpen\n\t\t\t\t\t? __( 'Scrollable block menu opened. Select a block.' )\n\t\t\t\t\t: __( 'Scrollable block menu closed.' );\n\t\t\t\tdelay(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tAccessibilityInfo.announceForAccessibility(\n\t\t\t\t\t\t\tannouncement\n\t\t\t\t\t\t),\n\t\t\t\t\tisIOS ? VOICE_OVER_ANNOUNCEMENT_DELAY : 0\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderInserterToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tgetStylesFromColorScheme,\n\t\t\tshowSeparator,\n\t\t} = this.props;\n\t\tif ( showSeparator && isOpen ) {\n\t\t\treturn <BlockInsertionPoint />;\n\t\t}\n\t\tconst style = getStylesFromColorScheme(\n\t\t\tstyles.addBlockButton,\n\t\t\tstyles.addBlockButtonDark\n\t\t);\n\n\t\tconst onPress = () => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock( 'default' ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( 'default' ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\tconst onLongPress = () => {\n\t\t\tif ( this.picker ) {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t};\n\n\t\tconst onPickerSelect = ( insertionType ) => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock(\n\t\t\t\t\t\tinsertionType\n\t\t\t\t\t),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( insertionType ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ renderToggle( {\n\t\t\t\t\tonToggle: onPress,\n\t\t\t\t\tisOpen,\n\t\t\t\t\tdisabled,\n\t\t\t\t\tstyle,\n\t\t\t\t\tonLongPress,\n\t\t\t\t} ) }\n\t\t\t\t<Picker\n\t\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\t\toptions={ this.getInsertionOptions() }\n\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\thideCancelButton\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose, isOpen } ) {\n\t\tconst { clientId, isAppender } = this.props;\n\t\tconst {\n\t\t\tdestinationRootClientId,\n\t\t\tshouldReplaceBlock,\n\t\t\tinsertionIndex,\n\t\t} = this.state;\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tisOpen={ isOpen }\n\t\t\t\tonSelect={ onClose }\n\t\t\t\tonDismiss={ onClose }\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshouldReplaceBlock={ shouldReplaceBlock }\n\t\t\t\tinsertionIndex={ insertionIndex }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderInserterToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { updateSettings } = dispatch( blockEditorStore );\n\t\treturn { updateSettings };\n\t} ),\n\twithSelect( ( select, { clientId, isAppender, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlock,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst end = getBlockSelectionEnd();\n\t\t// `end` argument (id) can refer to the component which is removed\n\t\t// due to pressing `undo` button, that's why we need to check\n\t\t// if `getBlock( end) is valid, otherwise `null` is passed\n\t\tconst isAnyBlockSelected = ! isAppender && end && getBlock( end );\n\t\tconst destinationRootClientId = isAnyBlockSelected\n\t\t\t? getBlockRootClientId( end )\n\t\t\t: rootClientId;\n\t\tconst selectedBlockIndex = getBlockIndex( end );\n\t\tconst endOfRootIndex = getBlockOrder( rootClientId ).length;\n\t\tconst isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected\n\t\t\t? isUnmodifiedDefaultBlock( getBlock( end ) )\n\t\t\t: undefined;\n\n\t\tfunction getDefaultInsertionIndex() {\n\t\t\tconst {\n\t\t\t\t__experimentalShouldInsertAtTheTop: shouldInsertAtTheTop,\n\t\t\t} = getBlockEditorSettings();\n\n\t\t\t// If post title is selected insert as first block.\n\t\t\tif ( shouldInsertAtTheTop ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there is a selected block,\n\t\t\tif ( isAnyBlockSelected ) {\n\t\t\t\t// And the last selected block is unmodified (empty), it will be replaced.\n\t\t\t\tif ( isSelectedUnmodifiedDefaultBlock ) {\n\t\t\t\t\treturn selectedBlockIndex;\n\t\t\t\t}\n\n\t\t\t\t// We insert after the selected block.\n\t\t\t\treturn selectedBlockIndex + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn endOfRootIndex;\n\t\t}\n\n\t\tconst insertionIndexStart = 0;\n\n\t\tconst insertionIndexBefore = isAnyBlockSelected\n\t\t\t? selectedBlockIndex\n\t\t\t: insertionIndexStart;\n\n\t\tconst insertionIndexAfter = isAnyBlockSelected\n\t\t\t? selectedBlockIndex + 1\n\t\t\t: endOfRootIndex;\n\n\t\tconst insertionIndexEnd = endOfRootIndex;\n\n\t\treturn {\n\t\t\tblockTypeImpressions: getBlockEditorSettings().impressions,\n\t\t\tdestinationRootClientId,\n\t\t\tinsertionIndexDefault: getDefaultInsertionIndex(),\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexEnd,\n\t\t\tisAnyBlockSelected: !! isAnyBlockSelected,\n\t\t\tisSelectedBlockReplaceable: isSelectedUnmodifiedDefaultBlock,\n\t\t};\n\t} ),\n\n\twithPreferredColorScheme,\n] )( Inserter );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.native.js"],"names":["VOICE_OVER_ANNOUNCEMENT_DELAY","defaultRenderToggle","onToggle","disabled","style","containerStyle","onLongPress","useExpandedMode","expandedModeViewProps","icon","plus","customContainerStyles","fixedRatio","expandedModeViewText","styles","plusCircleFilled","hint","testID","Inserter","Component","constructor","arguments","bind","renderInserterToggle","renderContent","getInsertionOptions","addBeforeOption","value","label","plusCircle","replaceCurrentOption","addAfterOption","addToBeginningOption","insertBefore","addToEndOption","insertAfter","isAnyBlockSelected","isSelectedBlockReplaceable","props","getInsertionIndex","insertionType","insertionIndexDefault","insertionIndexStart","insertionIndexBefore","insertionIndexAfter","insertionIndexEnd","shouldReplaceBlock","isOpen","blockTypeImpressions","updateSettings","impressionsRemain","Object","values","some","count","decrementedImpressions","entries","reduce","acc","blockName","Math","max","impressions","onInserterToggledAnnouncement","AccessibilityInfo","isScreenReaderEnabled","done","isEnabled","isIOS","Platform","OS","announcement","announceForAccessibility","renderToggle","getStylesFromColorScheme","showSeparator","onPress","setState","destinationRootClientId","insertionIndex","picker","presentPicker","onPickerSelect","instance","onClose","clientId","isAppender","state","render","dispatch","blockEditorStore","select","rootClientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","getBlock","getSettings","getBlockEditorSettings","end","selectedBlockIndex","endOfRootIndex","length","isSelectedUnmodifiedDefaultBlock","undefined","getDefaultInsertionIndex","__experimentalShouldInsertAtTheTop","shouldInsertAtTheTop","withPreferredColorScheme"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAQA;;AAKA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAIA;AACA;AACA;;AAiBA;AACA;AACA;AAMA,MAAMA,6BAA6B,GAAG,IAAtC;;AAEA,MAAMC,mBAAmB,GAAG,QAOrB;AAAA,MAPuB;AAC7BC,IAAAA,QAD6B;AAE7BC,IAAAA,QAF6B;AAG7BC,IAAAA,KAH6B;AAI7BC,IAAAA,cAJ6B;AAK7BC,IAAAA,WAL6B;AAM7BC,IAAAA;AAN6B,GAOvB;AACN;AACA;AACA;AACA;AACA,QAAMC,qBAAqB,GAAGD,eAAe,IAAI;AAChDE,IAAAA,IAAI,EAAE,4BAAC,WAAD;AAAM,MAAA,IAAI,EAAGC,WAAb;AAAoB,MAAA,KAAK,EAAGN;AAA5B,MAD0C;AAEhDO,IAAAA,qBAAqB,EAAEN,cAFyB;AAGhDO,IAAAA,UAAU,EAAE;AAHoC,GAAjD;AAKA,QAAMC,oBAAoB,GACzB,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGC,eAAQ,sCAAR;AAAd,KACG,cAAI,YAAJ,CADH,CADD;AAMA,SACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cACP,WADO,EAEP,yCAFO,CADT;AAKC,IAAA,IAAI,EAAG,4BAAC,WAAD;AAAM,MAAA,IAAI,EAAGC,uBAAb;AAAgC,MAAA,KAAK,EAAGX;AAAxC,MALR;AAMC,IAAA,OAAO,EAAGF,QANX;AAOC,IAAA,UAAU,EAAG;AACZc,MAAAA,IAAI,EAAE,cAAI,2BAAJ,CADM;AAEZ;AACA;AACAC,MAAAA,MAAM,EAAE,kBAJI;AAKZX,MAAAA;AALY,KAPd;AAcC,IAAA,UAAU,EAAGH;AAd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A0B;AACzB;AACA,UAAKoE,gCAAL,EAAwC;AACvC,eAAOH,kBAAP;AACA,OAJwB,CAMzB;;;AACA,aAAOA,kBAAkB,GAAG,CAA5B;AACA,KAxBkC,CA0BnC;;;AACA,WAAOC,cAAP;AACA;;AAED,QAAM5D,mBAAmB,GAAG,CAA5B;AAEA,QAAMC,oBAAoB,GAAGP,kBAAkB,GAC5CiE,kBAD4C,GAE5C3D,mBAFH;AAIA,QAAME,mBAAmB,GAAGR,kBAAkB,GAC3CiE,kBAAkB,GAAG,CADsB,GAE3CC,cAFH;AAIA,QAAMzD,iBAAiB,GAAGyD,cAA1B;AAEA,SAAO;AACNtD,IAAAA,oBAAoB,EAAEmD,sBAAsB,GAAGrC,WADzC;AAENgB,IAAAA,uBAFM;AAGNrC,IAAAA,qBAAqB,EAAEiE,wBAAwB,EAHzC;AAIN/D,IAAAA,oBAJM;AAKNC,IAAAA,mBALM;AAMNF,IAAAA,mBANM;AAONG,IAAAA,iBAPM;AAQNT,IAAAA,kBAAkB,EAAE,CAAC,CAAEA,kBARjB;AASNC,IAAAA,0BAA0B,EAAEmE;AATtB,GAAP;AAWA,CA7ED,CALuB,EAoFvBK,iCApFuB,CAAT,EAqFV3F,QArFU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Platform, Text } from 'react-native';\nimport { delay } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Dropdown, ToolbarButton, Picker } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport {\n\tIcon,\n\tplus,\n\tplusCircle,\n\tplusCircleFilled,\n\tinsertAfter,\n\tinsertBefore,\n} from '@wordpress/icons';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport InserterMenu from './menu';\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport { store as blockEditorStore } from '../../store';\n\nconst VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tstyle,\n\tcontainerStyle,\n\tonLongPress,\n\tuseExpandedMode,\n} ) => {\n\t// The \"expanded mode\" refers to the editor's appearance when no blocks\n\t// are currently selected. The \"add block\" button has a separate style\n\t// for the \"expanded mode\", which are added via the below \"expandedModeViewProps\"\n\t// and \"expandedModeViewText\" variables.\n\tconst expandedModeViewProps = useExpandedMode && {\n\t\ticon: <Icon icon={ plus } style={ style } />,\n\t\tcustomContainerStyles: containerStyle,\n\t\tfixedRatio: false,\n\t};\n\tconst expandedModeViewText = (\n\t\t<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>\n\t\t\t{ __( 'Add Blocks' ) }\n\t\t</Text>\n\t);\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\ttitle={ _x(\n\t\t\t\t'Add block',\n\t\t\t\t'Generic label for block inserter button'\n\t\t\t) }\n\t\t\ticon={ <Icon icon={ plusCircleFilled } style={ style } /> }\n\t\t\tonClick={ onToggle }\n\t\t\textraProps={ {\n\t\t\t\thint: __( 'Double tap to add a block' ),\n\t\t\t\t// testID is present to disambiguate this element for native UI tests. It's not\n\t\t\t\t// usually required for components. See: https://git.io/JeQ7G.\n\t\t\t\ttestID: 'add-block-button',\n\t\t\t\tonLongPress,\n\t\t\t} }\n\t\t\tisDisabled={ disabled }\n\t\t\t{ ...expandedModeViewProps }\n\t\t>\n\t\t\t{ useExpandedMode && expandedModeViewText }\n\t\t</ToolbarButton>\n\t);\n};\n\nexport class Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderInserterToggle = this.renderInserterToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tgetInsertionOptions() {\n\t\tconst addBeforeOption = {\n\t\t\tvalue: 'before',\n\t\t\tlabel: __( 'Add Block Before' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst replaceCurrentOption = {\n\t\t\tvalue: 'replace',\n\t\t\tlabel: __( 'Replace Current Block' ),\n\t\t\ticon: plusCircleFilled,\n\t\t};\n\n\t\tconst addAfterOption = {\n\t\t\tvalue: 'after',\n\t\t\tlabel: __( 'Add Block After' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst addToBeginningOption = {\n\t\t\tvalue: 'start',\n\t\t\tlabel: __( 'Add To Beginning' ),\n\t\t\ticon: insertBefore,\n\t\t};\n\n\t\tconst addToEndOption = {\n\t\t\tvalue: 'end',\n\t\t\tlabel: __( 'Add To End' ),\n\t\t\ticon: insertAfter,\n\t\t};\n\n\t\tconst { isAnyBlockSelected, isSelectedBlockReplaceable } = this.props;\n\t\tif ( isAnyBlockSelected ) {\n\t\t\tif ( isSelectedBlockReplaceable ) {\n\t\t\t\treturn [\n\t\t\t\t\taddToBeginningOption,\n\t\t\t\t\taddBeforeOption,\n\t\t\t\t\treplaceCurrentOption,\n\t\t\t\t\taddAfterOption,\n\t\t\t\t\taddToEndOption,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\taddToBeginningOption,\n\t\t\t\taddBeforeOption,\n\t\t\t\taddAfterOption,\n\t\t\t\taddToEndOption,\n\t\t\t];\n\t\t}\n\t\treturn [ addToBeginningOption, addToEndOption ];\n\t}\n\n\tgetInsertionIndex( insertionType ) {\n\t\tconst {\n\t\t\tinsertionIndexDefault,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexEnd,\n\t\t} = this.props;\n\t\tif ( insertionType === 'start' ) {\n\t\t\treturn insertionIndexStart;\n\t\t}\n\t\tif ( insertionType === 'before' || insertionType === 'replace' ) {\n\t\t\treturn insertionIndexBefore;\n\t\t}\n\t\tif ( insertionType === 'after' ) {\n\t\t\treturn insertionIndexAfter;\n\t\t}\n\t\tif ( insertionType === 'end' ) {\n\t\t\treturn insertionIndexEnd;\n\t\t}\n\t\treturn insertionIndexDefault;\n\t}\n\n\tshouldReplaceBlock( insertionType ) {\n\t\tconst { isSelectedBlockReplaceable } = this.props;\n\t\tif ( insertionType === 'replace' ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( insertionType === 'default' && isSelectedBlockReplaceable ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { blockTypeImpressions, onToggle, updateSettings } = this.props;\n\n\t\tif ( ! isOpen ) {\n\t\t\tconst impressionsRemain = Object.values(\n\t\t\t\tblockTypeImpressions\n\t\t\t).some( ( count ) => count > 0 );\n\n\t\t\tif ( impressionsRemain ) {\n\t\t\t\tconst decrementedImpressions = Object.entries(\n\t\t\t\t\tblockTypeImpressions\n\t\t\t\t).reduce(\n\t\t\t\t\t( acc, [ blockName, count ] ) => ( {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[ blockName ]: Math.max( count - 1, 0 ),\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\t// Persist block type impression to JavaScript store.\n\t\t\t\tupdateSettings( {\n\t\t\t\t\timpressions: decrementedImpressions,\n\t\t\t\t} );\n\n\t\t\t\t// Persist block type impression count to native app store.\n\t\t\t\tsetBlockTypeImpressions( decrementedImpressions );\n\t\t\t}\n\t\t}\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t\tthis.onInserterToggledAnnouncement( isOpen );\n\t}\n\n\tonInserterToggledAnnouncement( isOpen ) {\n\t\tAccessibilityInfo.isScreenReaderEnabled().done( ( isEnabled ) => {\n\t\t\tif ( isEnabled ) {\n\t\t\t\tconst isIOS = Platform.OS === 'ios';\n\t\t\t\tconst announcement = isOpen\n\t\t\t\t\t? __( 'Scrollable block menu opened. Select a block.' )\n\t\t\t\t\t: __( 'Scrollable block menu closed.' );\n\t\t\t\tdelay(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tAccessibilityInfo.announceForAccessibility(\n\t\t\t\t\t\t\tannouncement\n\t\t\t\t\t\t),\n\t\t\t\t\tisIOS ? VOICE_OVER_ANNOUNCEMENT_DELAY : 0\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderInserterToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tgetStylesFromColorScheme,\n\t\t\tshowSeparator,\n\t\t\tuseExpandedMode,\n\t\t} = this.props;\n\t\tif ( showSeparator && isOpen ) {\n\t\t\treturn <BlockInsertionPoint />;\n\t\t}\n\t\tconst style = useExpandedMode\n\t\t\t? styles[ 'inserter-menu__add-block-button-icon--expanded' ]\n\t\t\t: getStylesFromColorScheme(\n\t\t\t\t\tstyles[ 'inserter-menu__add-block-button-icon' ],\n\t\t\t\t\tstyles[ 'inserter-menu__add-block-button-icon--dark' ]\n\t\t\t );\n\n\t\tconst containerStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button--dark' ]\n\t\t);\n\n\t\tconst onPress = () => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock( 'default' ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( 'default' ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\tconst onLongPress = () => {\n\t\t\tif ( this.picker ) {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t};\n\n\t\tconst onPickerSelect = ( insertionType ) => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock(\n\t\t\t\t\t\tinsertionType\n\t\t\t\t\t),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( insertionType ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ renderToggle( {\n\t\t\t\t\tonToggle: onPress,\n\t\t\t\t\tisOpen,\n\t\t\t\t\tdisabled,\n\t\t\t\t\tstyle,\n\t\t\t\t\tcontainerStyle,\n\t\t\t\t\tonLongPress,\n\t\t\t\t\tuseExpandedMode,\n\t\t\t\t} ) }\n\t\t\t\t<Picker\n\t\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\t\toptions={ this.getInsertionOptions() }\n\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\thideCancelButton\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose, isOpen } ) {\n\t\tconst { clientId, isAppender } = this.props;\n\t\tconst {\n\t\t\tdestinationRootClientId,\n\t\t\tshouldReplaceBlock,\n\t\t\tinsertionIndex,\n\t\t} = this.state;\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tisOpen={ isOpen }\n\t\t\t\tonSelect={ onClose }\n\t\t\t\tonDismiss={ onClose }\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshouldReplaceBlock={ shouldReplaceBlock }\n\t\t\t\tinsertionIndex={ insertionIndex }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderInserterToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { updateSettings } = dispatch( blockEditorStore );\n\t\treturn { updateSettings };\n\t} ),\n\twithSelect( ( select, { clientId, isAppender, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlock,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst end = getBlockSelectionEnd();\n\t\t// `end` argument (id) can refer to the component which is removed\n\t\t// due to pressing `undo` button, that's why we need to check\n\t\t// if `getBlock( end) is valid, otherwise `null` is passed\n\t\tconst isAnyBlockSelected = ! isAppender && end && getBlock( end );\n\t\tconst destinationRootClientId = isAnyBlockSelected\n\t\t\t? getBlockRootClientId( end )\n\t\t\t: rootClientId;\n\t\tconst selectedBlockIndex = getBlockIndex( end );\n\t\tconst endOfRootIndex = getBlockOrder( rootClientId ).length;\n\t\tconst isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected\n\t\t\t? isUnmodifiedDefaultBlock( getBlock( end ) )\n\t\t\t: undefined;\n\n\t\tfunction getDefaultInsertionIndex() {\n\t\t\tconst {\n\t\t\t\t__experimentalShouldInsertAtTheTop: shouldInsertAtTheTop,\n\t\t\t} = getBlockEditorSettings();\n\n\t\t\t// If post title is selected insert as first block.\n\t\t\tif ( shouldInsertAtTheTop ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there is a selected block,\n\t\t\tif ( isAnyBlockSelected ) {\n\t\t\t\t// And the last selected block is unmodified (empty), it will be replaced.\n\t\t\t\tif ( isSelectedUnmodifiedDefaultBlock ) {\n\t\t\t\t\treturn selectedBlockIndex;\n\t\t\t\t}\n\n\t\t\t\t// We insert after the selected block.\n\t\t\t\treturn selectedBlockIndex + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn endOfRootIndex;\n\t\t}\n\n\t\tconst insertionIndexStart = 0;\n\n\t\tconst insertionIndexBefore = isAnyBlockSelected\n\t\t\t? selectedBlockIndex\n\t\t\t: insertionIndexStart;\n\n\t\tconst insertionIndexAfter = isAnyBlockSelected\n\t\t\t? selectedBlockIndex + 1\n\t\t\t: endOfRootIndex;\n\n\t\tconst insertionIndexEnd = endOfRootIndex;\n\n\t\treturn {\n\t\t\tblockTypeImpressions: getBlockEditorSettings().impressions,\n\t\t\tdestinationRootClientId,\n\t\t\tinsertionIndexDefault: getDefaultInsertionIndex(),\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexEnd,\n\t\t\tisAnyBlockSelected: !! isAnyBlockSelected,\n\t\t\tisSelectedBlockReplaceable: isSelectedUnmodifiedDefaultBlock,\n\t\t};\n\t} ),\n\n\twithPreferredColorScheme,\n] )( Inserter );\n"]}
|
|
@@ -57,8 +57,6 @@ var _store = require("../../store");
|
|
|
57
57
|
|
|
58
58
|
var _useUndoAutomaticChange = require("./use-undo-automatic-change");
|
|
59
59
|
|
|
60
|
-
var _useCaretInFormat = require("./use-caret-in-format");
|
|
61
|
-
|
|
62
60
|
var _useMarkPersistent = require("./use-mark-persistent");
|
|
63
61
|
|
|
64
62
|
var _usePasteHandler = require("./use-paste-handler");
|
|
@@ -294,9 +292,6 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
294
292
|
record: value,
|
|
295
293
|
onChange
|
|
296
294
|
});
|
|
297
|
-
(0, _useCaretInFormat.useCaretInFormat)({
|
|
298
|
-
value
|
|
299
|
-
});
|
|
300
295
|
(0, _useMarkPersistent.useMarkPersistent)({
|
|
301
296
|
html: adjustedValue,
|
|
302
297
|
value
|