@wordpress/block-editor 14.8.0 → 14.8.1-next.a9f418477.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/autocompleters/block.js +2 -4
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -4
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-canvas/index.js +3 -6
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-list/block.js +6 -5
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.js +0 -1
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +6 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +87 -0
- package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map +1 -0
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +98 -5
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-lock/modal.js +4 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-parent-selector/index.js +2 -15
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +13 -4
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -0
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +7 -4
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +12 -22
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-switcher/utils.js +0 -1
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-toolbar/index.js +7 -6
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +0 -1
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +0 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +1 -0
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +10 -0
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +17 -16
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +0 -1
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/iframe/use-scale-canvas.js +68 -47
- package/build/components/iframe/use-scale-canvas.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +0 -10
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/menu.js +2 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +19 -10
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +2 -13
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +10 -0
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +1 -0
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +18 -18
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +9 -25
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/observe-typing/index.js +0 -1
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +0 -1
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +5 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/native/use-format-types.js +0 -1
- package/build/components/rich-text/native/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +0 -1
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +0 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +0 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +11 -2
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +15 -2
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/warning/index.js +2 -3
- package/build/components/warning/index.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +11 -0
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +6 -2
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/block-bindings.js +4 -3
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/gap.js +1 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +0 -1
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/use-zoom-out.js +47 -14
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/store/private-selectors.js +1 -7
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +478 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +12 -55
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +0 -1
- package/build/utils/object.js.map +1 -1
- package/build-module/autocompleters/block.js +2 -4
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -4
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-canvas/index.js +3 -6
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-list/block.js +8 -7
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.js +0 -1
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +6 -2
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +80 -0
- package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map +1 -0
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +97 -5
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-lock/modal.js +4 -4
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +2 -15
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +13 -4
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +13 -23
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +0 -1
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -6
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +0 -1
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +0 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +1 -0
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +10 -0
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +17 -16
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +0 -1
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/iframe/use-scale-canvas.js +68 -47
- package/build-module/components/iframe/use-scale-canvas.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -11
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +20 -11
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +3 -14
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -0
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +1 -0
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +18 -18
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +9 -25
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +0 -1
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +0 -1
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +5 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/native/use-format-types.js +0 -1
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +0 -1
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +0 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +0 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +11 -2
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +15 -2
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/warning/index.js +2 -3
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +11 -0
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +6 -2
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/block-bindings.js +4 -3
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/gap.js +1 -1
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +0 -1
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +48 -15
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +479 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +12 -55
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +0 -1
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +18 -5
- package/build-style/content.css +18 -5
- package/build-style/style-rtl.css +25 -64
- package/build-style/style.css +25 -64
- package/package.json +32 -32
- package/src/autocompleters/block.js +2 -4
- package/src/autocompleters/link.js +2 -4
- package/src/components/alignment-control/stories/aliginment-toolbar.story.js +47 -0
- package/src/components/alignment-control/stories/index.story.js +51 -0
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +5 -5
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +4 -4
- package/src/components/block-canvas/index.js +3 -5
- package/src/components/block-draggable/content.scss +11 -5
- package/src/components/block-list/block.js +7 -13
- package/src/components/block-list/content.scss +6 -0
- package/src/components/block-list/use-block-props/index.js +5 -0
- package/src/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +83 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +112 -8
- package/src/components/block-lock/modal.js +4 -6
- package/src/components/block-parent-selector/index.js +1 -19
- package/src/components/block-patterns-list/index.js +12 -1
- package/src/components/block-patterns-list/stories/fixtures.js +1 -0
- package/src/components/block-patterns-list/style.scss +16 -5
- package/src/components/block-popover/inbetween.js +4 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +6 -1
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-switcher/index.js +19 -21
- package/src/components/block-switcher/style.scss +0 -9
- package/src/components/block-title/test/index.js +2 -0
- package/src/components/block-toolbar/index.js +9 -6
- package/src/components/block-tools/style.scss +5 -0
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/dimensions-tool/stories/aspect-ratio-tool.story.js +1 -1
- package/src/components/dimensions-tool/stories/index.story.js +1 -1
- package/src/components/dimensions-tool/stories/scale-tool.story.js +1 -1
- package/src/components/dimensions-tool/stories/width-height-tool.story.js +1 -1
- package/src/components/font-appearance-control/index.js +1 -0
- package/src/components/font-family/index.js +10 -0
- package/src/components/font-family/style.scss +5 -0
- package/src/components/global-styles/dimensions-panel.js +16 -16
- package/src/components/iframe/content.scss +6 -1
- package/src/components/iframe/use-scale-canvas.js +103 -81
- package/src/components/inserter/block-patterns-tab/index.js +1 -17
- package/src/components/inserter/menu.js +8 -1
- package/src/components/inserter-draggable-blocks/index.js +19 -29
- package/src/components/inspector-controls/slot.js +3 -22
- package/src/components/letter-spacing-control/README.md +2 -1
- package/src/components/letter-spacing-control/index.js +17 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/media-placeholder/index.js +25 -28
- package/src/components/multi-selection-inspector/index.js +17 -27
- package/src/components/multi-selection-inspector/style.scss +0 -12
- package/src/components/resolution-tool/stories/index.story.js +1 -1
- package/src/components/rich-text/index.js +5 -0
- package/src/components/spacing-sizes-control/style.scss +0 -29
- package/src/components/text-alignment-control/stories/index.story.js +1 -1
- package/src/components/use-block-drop-zone/index.js +18 -1
- package/src/components/use-moving-animation/index.js +15 -0
- package/src/components/use-resize-canvas/index.js +1 -1
- package/src/components/warning/index.js +3 -4
- package/src/components/warning/test/index.js +3 -1
- package/src/components/writing-flow/use-drag-selection.js +11 -0
- package/src/components/writing-flow/use-tab-nav.js +9 -6
- package/src/hooks/block-bindings.js +8 -4
- package/src/hooks/gap.js +1 -1
- package/src/hooks/use-zoom-out.js +48 -16
- package/src/store/private-selectors.js +2 -17
- package/src/store/reducer.js +639 -2
- package/src/store/selectors.js +19 -69
- package/src/store/test/private-selectors.js +1 -0
- package/src/store/test/reducer.js +849 -0
- package/src/store/test/selectors.js +4 -110
- package/src/style.scss +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","filter","name","tagName","includes","has","keyedSelected","reduce","accumulator","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","forEach","__experimentalCreatePrepareEditableTree","selected","handler","__experimentalCreateOnChangeEditableValue","push","key","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"sources":["@wordpress/block-editor/src/components/rich-text/native/use-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\tinteractiveContentTags.has( tagName )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, interactiveContentTags ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\taccumulator[ type.name ] =\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst selected = keyedSelected[ type.name ];\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tselected,\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\n\t\t\tfor ( const key in selected ) {\n\t\t\t\tdependencies.push( selected[ key ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( keyedSelected[ type.name ] || {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","filter","name","tagName","includes","has","keyedSelected","reduce","accumulator","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","forEach","__experimentalCreatePrepareEditableTree","selected","handler","__experimentalCreateOnChangeEditableValue","push","key","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"sources":["@wordpress/block-editor/src/components/rich-text/native/use-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\tinteractiveContentTags.has( tagName )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, interactiveContentTags ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\taccumulator[ type.name ] =\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst selected = keyedSelected[ type.name ];\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tselected,\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\n\t\t\tfor ( const key in selected ) {\n\t\t\t\tdependencies.push( selected[ key ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( keyedSelected[ type.name ] || {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAE7D,SAASC,mBAAmBA,CAAEC,MAAM,EAAG;EACtC,OAAOA,MAAM,CAAEF,aAAc,CAAC,CAACG,cAAc,CAAC,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAG,CAAE,CACvC,GAAG,EACH,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,CACN,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAE;EAC/BC,QAAQ;EACRC,UAAU;EACVC,4BAA4B;EAC5BC;AACD,CAAC,EAAG;EACH,MAAMC,cAAc,GAAGd,SAAS,CAAE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,MAAMmB,OAAO,GAAGZ,IAAI,CAACU,uCAAuC,CAC3DC,QAAQ,EACR;QACCT,kBAAkB,EAAEf,UAAU;QAC9BgB,aAAa,EAAEjB;MAChB,CACD,CAAC;MAED,IAAKc,IAAI,CAACa,yCAAyC,EAAG;QACrDP,aAAa,CAACQ,IAAI,CAAEF,OAAQ,CAAC;MAC9B,CAAC,MAAM;QACNP,eAAe,CAACS,IAAI,CAAEF,OAAQ,CAAC;MAChC;MAEA,KAAM,MAAMG,GAAG,IAAIJ,QAAQ,EAAG;QAC7BH,YAAY,CAACM,IAAI,CAAEH,QAAQ,CAAEI,GAAG,CAAG,CAAC;MACrC;IACD;IAEA,IAAKf,IAAI,CAACa,yCAAyC,EAAG;MACrD,IAAIG,WAAW,GAAG,CAAC,CAAC;MAEpB,IAAKhB,IAAI,CAACiB,kDAAkD,EAAG;QAC9DD,WAAW,GACVhB,IAAI,CAACiB,kDAAkD,CACtDb,QAAQ,EACR;UACCF,kBAAkB,EAAEf,UAAU;UAC9BgB,aAAa,EAAEjB;QAChB,CACD,CAAC;MACH;MAEAqB,cAAc,CAACO,IAAI,CAClBd,IAAI,CAACa,yCAAyC,CAC7C;QACC,IAAKhB,aAAa,CAAEG,IAAI,CAACP,IAAI,CAAE,IAAI,CAAC,CAAC,CAAE;QACvC,GAAGuB;MACJ,CAAC,EACD;QACCd,kBAAkB,EAAEf,UAAU;QAC9BgB,aAAa,EAAEjB;MAChB,CACD,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEH,OAAO;IACNK,WAAW;IACXc,eAAe;IACfC,aAAa;IACbC,cAAc;IACdC;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","Object","fromEntries","entries","map","key","value","getPrefixedSelectKeys","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","interactive","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\nfunction prefixSelectKeys( selected, prefix ) {\n\tif ( typeof selected !== 'object' ) {\n\t\treturn { [ prefix ]: selected };\n\t}\n\treturn Object.fromEntries(\n\t\tObject.entries( selected ).map( ( [ key, value ] ) => [\n\t\t\t`${ prefix }.${ key }`,\n\t\t\tvalue,\n\t\t] )\n\t);\n}\n\nfunction getPrefixedSelectKeys( selected, prefix ) {\n\tif ( selected[ prefix ] ) {\n\t\treturn selected[ prefix ];\n\t}\n\treturn Object.keys( selected )\n\t\t.filter( ( key ) => key.startsWith( prefix + '.' ) )\n\t\t.reduce( ( accumulator, key ) => {\n\t\t\taccumulator[ key.slice( prefix.length + 1 ) ] = selected[ key ];\n\t\t\treturn accumulator;\n\t\t}, {} );\n}\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, interactive, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\t( interactive || interactiveContentTags.has( tagName ) )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, withoutInteractiveFormatting ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( ! type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulator,\n\t\t\t\t\t...prefixSelectKeys(\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype.name\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tfor ( const key in keyedSelected ) {\n\t\tdependencies.push( keyedSelected[ key ] );\n\t}\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tgetPrefixedSelectKeys( keyedSelected, type.name ),\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst selected = getPrefixedSelectKeys( keyedSelected, type.name );\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( typeof selected === 'object' ? selected : {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","Object","fromEntries","entries","map","key","value","getPrefixedSelectKeys","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","interactive","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\nfunction prefixSelectKeys( selected, prefix ) {\n\tif ( typeof selected !== 'object' ) {\n\t\treturn { [ prefix ]: selected };\n\t}\n\treturn Object.fromEntries(\n\t\tObject.entries( selected ).map( ( [ key, value ] ) => [\n\t\t\t`${ prefix }.${ key }`,\n\t\t\tvalue,\n\t\t] )\n\t);\n}\n\nfunction getPrefixedSelectKeys( selected, prefix ) {\n\tif ( selected[ prefix ] ) {\n\t\treturn selected[ prefix ];\n\t}\n\treturn Object.keys( selected )\n\t\t.filter( ( key ) => key.startsWith( prefix + '.' ) )\n\t\t.reduce( ( accumulator, key ) => {\n\t\t\taccumulator[ key.slice( prefix.length + 1 ) ] = selected[ key ];\n\t\t\treturn accumulator;\n\t\t}, {} );\n}\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, interactive, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\t( interactive || interactiveContentTags.has( tagName ) )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, withoutInteractiveFormatting ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( ! type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulator,\n\t\t\t\t\t...prefixSelectKeys(\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype.name\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tfor ( const key in keyedSelected ) {\n\t\tdependencies.push( keyedSelected[ key ] );\n\t}\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tgetPrefixedSelectKeys( keyedSelected, type.name ),\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst selected = getPrefixedSelectKeys( keyedSelected, type.name );\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( typeof selected === 'object' ? selected : {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"],"mappings":"AAAA;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G,CAAC,CAAC,CAAE;QACnD,GAAG2C;MACJ,CAAC,EACD;QACCZ,kBAAkB,EAAEb,UAAU;QAC9Bc,aAAa,EAAEf;MAChB,CACD,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEH,OAAO;IACNK,WAAW;IACXY,eAAe;IACfC,aAAa;IACbC,cAAc;IACdC;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sidesAll","sidesBottom","sidesHorizontal","sidesLeft","sidesRight","sidesTop","sidesVertical","RANGE_CONTROL_MAX_SIZE","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","axial","horizontal","vertical","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","hasOnlyAxialSides","entries","some","key"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const RANGE_CONTROL_MAX_SIZE = 8;\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAll,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Only axial sides are supported and single value defined.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( hasOnlyAxialSides && sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,QAAQ,EACRC,WAAW,EACXC,eAAe,EACfC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,aAAa,QACP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AE;EAClB;;EAEA;EACA,OAAOnC,KAAK,CAACP,MAAM;AACpB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","sidesAll","sidesBottom","sidesHorizontal","sidesLeft","sidesRight","sidesTop","sidesVertical","RANGE_CONTROL_MAX_SIZE","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","axial","horizontal","vertical","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","hasOnlyAxialSides","entries","some","key"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const RANGE_CONTROL_MAX_SIZE = 8;\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAll,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Only axial sides are supported and single value defined.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( hasOnlyAxialSides && sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,QAAQ,EACRC,WAAW,EACXC,eAAe,EACfC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,aAAa,QACP,kBAAkB;AAEzB,OAAO,MAAMC,sBAAsB,GAAG,CAAC;AAEvC,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAE;AAE7D,OAAO,MAAMC,cAAc,GAAG;EAC7BC,GAAG,EAAEC,SAA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AAEC,MAAM,EAAEC,IAAI,CAAE,CAACoC,MAAM,CAAE0B,OAAQ,CAAC;;EAEjE;EACA;EACA;EACA;EACA,MAAMC,sBAAsB,GAC3BnE,GAAG,KAAKG,MAAM,IAAIC,IAAI,KAAKF,KAAK,KAAM,CAAC,CAAEF,GAAG,IAAI,CAAC,CAAEI,IAAI,CAAE;EAC1D,MAAMgE,2BAA2B,GAChC,CAAEH,UAAU,CAACvB,MAAM,IAAIoB,uBAAuB,CAAEd,KAAM,CAAC;EACxD,MAAMqB,iBAAiB,GACtBrB,KAAK,EAAEhC,QAAQ,CAAE,YAAa,CAAC,IAC/BgC,KAAK,EAAEhC,QAAQ,CAAE,UAAW,CAAC,IAC7BgC,KAAK,EAAEN,MAAM,KAAK,CAAC;EAEpB,IACCS,cAAc,CAAEH,KAAM,CAAC,KACrBmB,sBAAsB,IAAIC,2BAA2B,CAAE,EACxD;IACD,OAAOvD,KAAK,CAACN,KAAK;EACnB;;EAEA;EACA;EACA,IAAK8D,iBAAiB,IAAIJ,UAAU,CAACvB,MAAM,KAAK,CAAC,EAAG;IACnD,IAAImB,IAAI;IAERf,MAAM,CAACwB,OAAO,CAAEzB,MAAO,CAAC,CAAC0B,IAAI,CAAE,CAAE,CAAEC,GAAG,EAAEzD,KAAK,CAAE,KAAM;MACpD8C,IAAI,GAAGW,GAAG;MACV,OAAOzD,KAAK,KAAKd,SAAS;IAC3B,CAAE,CAAC;IAEH,OAAO4D,IAAI;EACZ;;EAEA;EACA,IAAKb,KAAK,EAAEN,MAAM,KAAK,CAAC,IAAI,CAAEuB,UAAU,CAACvB,MAAM,EAAG;IACjD,OAAOM,KAAK,CAAE,CAAC,CAAE;EAClB;;EAEA;EACA,OAAOnC,KAAK,CAACP,MAAM;AACpB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRefEffect","computeCaretRect","getScrollContainer","useSelect","UP","DOWN","LEFT","RIGHT","store","blockEditorStore","jsx","_jsx","isIE","window","navigator","userAgent","indexOf","arrowKeyCodes","Set","initialTriggerPercentage","useTypewriter","hasSelectedBlock","select","node","ownerDocument","defaultView","scrollResizeRafId","onKeyDownRafId","caretRect","onScrollResize","requestAnimationFrame","computeCaretRectangle","onKeyDown","event","cancelAnimationFrame","maintainCaretPosition","keyCode","isSelectionEligibleForScroll","currentCaretRect","has","diff","top","scrollContainer","windowScroll","body","documentElement","scrollY","scrollTop","scrollContainerY","getBoundingClientRect","relativeScrollPosition","innerHeight","isLastEditableNode","scrollContainerHeight","clientHeight","height","scrollBy","addSelectionChangeListener","addEventListener","computeCaretRectOnSelectionChange","removeEventListener","contains","activeElement","isContentEditable","editableNodes","querySelectorAll","lastEditableNode","length","Typewriter","children","ref","className","TypewriterOrIEBypass","props"],"sources":["@wordpress/block-editor/src/components/typewriter/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\tconst hasSelectedBlock = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasSelectedBlock(),\n\t\t[]\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! hasSelectedBlock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet scrollResizeRafId;\n\t\t\tlet onKeyDownRafId;\n\n\t\t\tlet caretRect;\n\n\t\t\tfunction onScrollResize() {\n\t\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tcomputeCaretRectangle();\n\t\t\t\t\tscrollResizeRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t\t}\n\n\t\t\t\t// Use an animation frame for a smooth result.\n\t\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\t\tonKeyDownRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Maintains the scroll position after a selection change caused by a\n\t\t\t * keyboard event.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t\t */\n\t\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t\t// this be the position to be scrolled to in the future.\n\t\t\t\tif ( ! caretRect ) {\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t\t// now, let's disable it.\n\t\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\t\tif ( diff === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t\t// The page must be scrollable.\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\t\tconst scrollY = windowScroll\n\t\t\t\t\t? defaultView.scrollY\n\t\t\t\t\t: scrollContainer.scrollTop;\n\t\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t\t? 0\n\t\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t\t// intentionally down.\n\t\t\t\tif (\n\t\t\t\t\tscrollY === 0 &&\n\t\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\t\tisLastEditableNode()\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t\t? defaultView.innerHeight\n\t\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t\t// view.\n\t\t\t\tif (\n\t\t\t\t\t// The caret is under the lower fold.\n\t\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t\t// The caret is above the upper fold.\n\t\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( windowScroll ) {\n\t\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t\t} else {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t\t * maintained.\n\t\t\t */\n\t\t\tfunction addSelectionChangeListener() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t\t */\n\t\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained.\n\t\t\t */\n\t\t\tfunction computeCaretRectangle() {\n\t\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Checks if the current situation is elegible for scroll:\n\t\t\t * - There should be one and only one block selected.\n\t\t\t * - The component must contain the selection.\n\t\t\t * - The active element must be contenteditable.\n\t\t\t */\n\t\t\tfunction isSelectionEligibleForScroll() {\n\t\t\t\treturn (\n\t\t\t\t\tnode.contains( ownerDocument.activeElement ) &&\n\t\t\t\t\townerDocument.activeElement.isContentEditable\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction isLastEditableNode() {\n\t\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t\t);\n\t\t\t\tconst lastEditableNode =\n\t\t\t\t\teditableNodes[ editableNodes.length - 1 ];\n\t\t\t\treturn lastEditableNode === ownerDocument.activeElement;\n\t\t\t}\n\n\t\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t\t// reset.\n\t\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\t\treturn () => {\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'scroll',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'resize',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'touchstart',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\n\t\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t};\n\t\t},\n\t\t[ hasSelectedBlock ]\n\t);\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,gBAAgB;AACrE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,QAAQ,qBAAqB;;AAE3D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,IAAI,GAAGC,MAAM,CAACC,SAAS,CAACC,SAAS,CAACC,OAAO,CAAE,SAAU,CAAC,KAAK,CAAC,CAAC;AACnE,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAE,CAAEd,EAAE,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,CAAG,CAAC;AAC1D,MAAMY,wBAAwB,GAAG,IAAI;AAErC,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC/B,MAAMC,gBAAgB,GAAGlB,SAAS,CAC/BmB,MAAM,IAAMA,MAAM,CAAEb,gBAAiB,CAAC,CAACY,gBAAgB,CAAC,CAAC,EAC3D,EACD,CAAC;EAED,OAAOrB,YAAY,CAChBuB,IAAI,IAAM;IACX,IAAK,CAAEF,gBAAgB,EAAG;MACzB;IACD;IA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AAmB,CAC9B,QAAQ,EACR/B,cAAc,EACd,IACD,CAAC;MACDJ,WAAW,CAACmC,mBAAmB,CAC9B,QAAQ,EACR/B,cAAc,EACd,IACD,CAAC;MAEDN,IAAI,CAACqC,mBAAmB,CAAE,SAAS,EAAE5B,SAAU,CAAC;MAChDT,IAAI,CAACqC,mBAAmB,CAAE,OAAO,EAAEzB,qBAAsB,CAAC;MAC1DZ,IAAI,CAACqC,mBAAmB,CACvB,WAAW,EACXH,0BACD,CAAC;MACDlC,IAAI,CAACqC,mBAAmB,CACvB,YAAY,EACZH,0BACD,CAAC;MAEDjC,aAAa,CAACoC,mBAAmB,CAChC,iBAAiB,EACjBD,iCACD,CAAC;MAEDlC,WAAW,CAACS,oBAAoB,CAAER,iBAAkB,CAAC;MACrDD,WAAW,CAACS,oBAAoB,CAAEP,cAAe,CAAC;IACnD,CAAC;EACF,CAAC,EACD,CAAEN,gBAAgB,CACnB,CAAC;AACF;AAEA,SAAS+C,UAAUA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnC,oBACC1D,IAAA;IAAK2D,GAAG,EAAGlD,aAAa,CAAC,CAAG;IAACmD,SAAS,EAAC,0BAA0B;IAAAF,QAAA,EAC9DA;EAAQ,CACN,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,oBAAoB,GAAG5D,IAAI,GAAK6D,KAAK,IAAMA,KAAK,CAACJ,QAAQ,GAAGD,UAAU;;AAE5E;AACA;AACA;AACA;AACA;AACA,eAAeI,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRefEffect","computeCaretRect","getScrollContainer","useSelect","UP","DOWN","LEFT","RIGHT","store","blockEditorStore","jsx","_jsx","isIE","window","navigator","userAgent","indexOf","arrowKeyCodes","Set","initialTriggerPercentage","useTypewriter","hasSelectedBlock","select","node","ownerDocument","defaultView","scrollResizeRafId","onKeyDownRafId","caretRect","onScrollResize","requestAnimationFrame","computeCaretRectangle","onKeyDown","event","cancelAnimationFrame","maintainCaretPosition","keyCode","isSelectionEligibleForScroll","currentCaretRect","has","diff","top","scrollContainer","windowScroll","body","documentElement","scrollY","scrollTop","scrollContainerY","getBoundingClientRect","relativeScrollPosition","innerHeight","isLastEditableNode","scrollContainerHeight","clientHeight","height","scrollBy","addSelectionChangeListener","addEventListener","computeCaretRectOnSelectionChange","removeEventListener","contains","activeElement","isContentEditable","editableNodes","querySelectorAll","lastEditableNode","length","Typewriter","children","ref","className","TypewriterOrIEBypass","props"],"sources":["@wordpress/block-editor/src/components/typewriter/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\tconst hasSelectedBlock = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasSelectedBlock(),\n\t\t[]\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! hasSelectedBlock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet scrollResizeRafId;\n\t\t\tlet onKeyDownRafId;\n\n\t\t\tlet caretRect;\n\n\t\t\tfunction onScrollResize() {\n\t\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tcomputeCaretRectangle();\n\t\t\t\t\tscrollResizeRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t\t}\n\n\t\t\t\t// Use an animation frame for a smooth result.\n\t\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\t\tonKeyDownRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Maintains the scroll position after a selection change caused by a\n\t\t\t * keyboard event.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t\t */\n\t\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t\t// this be the position to be scrolled to in the future.\n\t\t\t\tif ( ! caretRect ) {\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t\t// now, let's disable it.\n\t\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\t\tif ( diff === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t\t// The page must be scrollable.\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\t\tconst scrollY = windowScroll\n\t\t\t\t\t? defaultView.scrollY\n\t\t\t\t\t: scrollContainer.scrollTop;\n\t\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t\t? 0\n\t\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t\t// intentionally down.\n\t\t\t\tif (\n\t\t\t\t\tscrollY === 0 &&\n\t\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\t\tisLastEditableNode()\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t\t? defaultView.innerHeight\n\t\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t\t// view.\n\t\t\t\tif (\n\t\t\t\t\t// The caret is under the lower fold.\n\t\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t\t// The caret is above the upper fold.\n\t\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( windowScroll ) {\n\t\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t\t} else {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t\t * maintained.\n\t\t\t */\n\t\t\tfunction addSelectionChangeListener() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t\t */\n\t\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained.\n\t\t\t */\n\t\t\tfunction computeCaretRectangle() {\n\t\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Checks if the current situation is elegible for scroll:\n\t\t\t * - There should be one and only one block selected.\n\t\t\t * - The component must contain the selection.\n\t\t\t * - The active element must be contenteditable.\n\t\t\t */\n\t\t\tfunction isSelectionEligibleForScroll() {\n\t\t\t\treturn (\n\t\t\t\t\tnode.contains( ownerDocument.activeElement ) &&\n\t\t\t\t\townerDocument.activeElement.isContentEditable\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction isLastEditableNode() {\n\t\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t\t);\n\t\t\t\tconst lastEditableNode =\n\t\t\t\t\teditableNodes[ editableNodes.length - 1 ];\n\t\t\t\treturn lastEditableNode === ownerDocument.activeElement;\n\t\t\t}\n\n\t\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t\t// reset.\n\t\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\t\treturn () => {\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'scroll',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'resize',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'touchstart',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\n\t\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t};\n\t\t},\n\t\t[ hasSelectedBlock ]\n\t);\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,gBAAgB;AACrE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,QAAQ,qBAAqB;;AAE3D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,IAAI,GAAGC,MAAM,CAACC,SAAS,CAACC,SAAS,CAACC,OAAO,CAAE,SAAU,CAAC,KAAK,CAAC,CAAC;AACnE,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAE,CAAEd,EAAE,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,CAAG,CAAC;AAC1D,MAAMY,wBAAwB,GAAG,IAAI;AAErC,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC/B,MAAMC,gBAAgB,GAAGlB,SAAS,CAC/BmB,MAAM,IAAMA,MAAM,CAAEb,gBAAiB,CAAC,CAACY,gBAAgB,CAAC,CAAC,EAC3D,EACD,CAAC;EAED,OAAOrB,YAAY,CAChBuB,IAAI,IAAM;IACX,IAAK,CAAEF,gBAAgB,EAAG;MACzB;IACD;IAEA,MAAM;MAAEG;IAAc,CAAC,GAAGD,IAAI;IAC9B,MAAM;MAAEE;IAAY,CAAC,GAAGD,aAAa;IAErC,IAAIE,iBAAiB;IACrB,IAAIC,cAAc;IAElB,IAAIC,SAAS;IAEb,SAASC,cAA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AAE5B,SAAU,CAAC;MAChDT,IAAI,CAACqC,mBAAmB,CAAE,OAAO,EAAEzB,qBAAsB,CAAC;MAC1DZ,IAAI,CAACqC,mBAAmB,CACvB,WAAW,EACXH,0BACD,CAAC;MACDlC,IAAI,CAACqC,mBAAmB,CACvB,YAAY,EACZH,0BACD,CAAC;MAEDjC,aAAa,CAACoC,mBAAmB,CAChC,iBAAiB,EACjBD,iCACD,CAAC;MAEDlC,WAAW,CAACS,oBAAoB,CAAER,iBAAkB,CAAC;MACrDD,WAAW,CAACS,oBAAoB,CAAEP,cAAe,CAAC;IACnD,CAAC;EACF,CAAC,EACD,CAAEN,gBAAgB,CACnB,CAAC;AACF;AAEA,SAAS+C,UAAUA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnC,oBACC1D,IAAA;IAAK2D,GAAG,EAAGlD,aAAa,CAAC,CAAG;IAACmD,SAAS,EAAC,0BAA0B;IAAAF,QAAA,EAC9DA;EAAQ,CACN,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,oBAAoB,GAAG5D,IAAI,GAAK6D,KAAK,IAAMA,KAAK,CAACJ,QAAQ,GAAGD,UAAU;;AAE5E;AACA;AACA;AACA;AACA;AACA,eAAeI,oBAAoB","ignoreList":[]}
|
|
@@ -239,7 +239,8 @@ export default function useBlockDropZone({
|
|
|
239
239
|
isDragging,
|
|
240
240
|
isGroupable,
|
|
241
241
|
isZoomOut,
|
|
242
|
-
getSectionRootClientId
|
|
242
|
+
getSectionRootClientId,
|
|
243
|
+
getBlockParents
|
|
243
244
|
} = unlock(useSelect(blockEditorStore));
|
|
244
245
|
const {
|
|
245
246
|
showInsertionPoint,
|
|
@@ -257,9 +258,17 @@ export default function useBlockDropZone({
|
|
|
257
258
|
// So, ensure that the drag state is set when the user drags over a drop zone.
|
|
258
259
|
startDragging();
|
|
259
260
|
}
|
|
261
|
+
const draggedBlockClientIds = getDraggedBlockClientIds();
|
|
262
|
+
const targetParents = [targetRootClientId, ...getBlockParents(targetRootClientId, true)];
|
|
263
|
+
|
|
264
|
+
// Check if the target is within any of the dragged blocks.
|
|
265
|
+
const isTargetWithinDraggedBlocks = draggedBlockClientIds.some(clientId => targetParents.includes(clientId));
|
|
266
|
+
if (isTargetWithinDraggedBlocks) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
260
269
|
const allowedBlocks = getAllowedBlocks(targetRootClientId);
|
|
261
270
|
const targetBlockName = getBlockNamesByClientId([targetRootClientId])[0];
|
|
262
|
-
const draggedBlockNames = getBlockNamesByClientId(
|
|
271
|
+
const draggedBlockNames = getBlockNamesByClientId(draggedBlockClientIds);
|
|
263
272
|
const isBlockDroppingAllowed = isDropTargetValid(getBlockType, allowedBlocks, draggedBlockNames, targetBlockName);
|
|
264
273
|
if (!isBlockDroppingAllowed) {
|
|
265
274
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useSelect","useRegistry","useCallback","useState","useThrottle","__experimentalUseDropZone","useDropZone","isRTL","isUnmodifiedDefaultBlock","getIsUnmodifiedDefaultBlock","store","blocksStore","useOnBlockDrop","getDistanceToNearestEdge","isPointContainedByRect","isPointWithinTopAndBottomBoundariesOfRect","blockEditorStore","unlock","THRESHOLD_DISTANCE","MINIMUM_HEIGHT_FOR_THRESHOLD","MINIMUM_WIDTH_FOR_THRESHOLD","getDropTargetPosition","blocksData","position","orientation","options","allowedEdges","nearestIndex","insertPosition","minDistance","Infinity","targetBlockIndex","nearestSide","dropZoneElement","parentBlockOrientation","rootBlockIndex","rect","getBoundingClientRect","distance","edge","height","isRightToLeft","width","forEach","blockIndex","blockOrientation","sideDistance","sideEdge","isPointInsideRect","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","isDropTargetValid","getBlockType","allowedBlocks","draggedBlockNames","targetBlockName","areBlocksAllowed","allowedBlockNames","map","name","every","includes","draggedBlockTypes","targetMatchesDraggedBlockParents","block","allowedParentName","parent","isInsertionPoint","targetToCheck","ownerDocument","defaultView","HTMLElement","closest","useBlockDropZone","rootClientId","targetRootClientId","parentClientId","parentBlockClientId","isDisabled","registry","dropTarget","setDropTarget","index","operation","getBlockVariations","getGroupingBlockName","canInsertBlockType","getBlockListSettings","getBlocks","getBlockIndex","getDraggedBlockClientIds","getBlockNamesByClientId","getAllowedBlocks","isDragging","isGroupable","isZoomOut","getSectionRootClientId","showInsertionPoint","hideInsertionPoint","startDragging","stopDragging","onBlockDrop","throttled","event","isBlockDroppingAllowed","sectionRootClientId","blocks","length","batch","clientId","getElementById","dropTargetPosition","x","clientX","y","clientY","undefined","targetIndex","targetBlock","areAllImages","canInsertGalleryBlock","areGroupableBlocks","groupBlockVariations","canInsertRow","find","insertionPointClientId","onDrop","onDragOver","currentTarget","onDragLeave","relatedTarget","target","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.closest( '[data-is-insertion-point]' )\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOut,\n\t\tgetSectionRootClientId,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tgetDraggedBlockClientIds()\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tif ( isZoomOut() && operation !== 'insert' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACrE,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;AAC1D,SACCC,WAAW,EACXC,yBAAyB,IAAIC,WAAW,QAClC,oBAAoB;AAC3B,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SACCC,wBAAwB,IAAIC,2BAA2B,EACvDC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,OAAOC,cAAc,MAAM,sBAAsB;AACjD,SACCC,wBAAwB,EACxBC,sBAAsB,EACtBC,yCAAyC,QACnC,kBAAkB;AACzB,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,aAAa;AACvD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,4BAA4B,GAAG,GAAG;AACxC,MAAMC,2BAA2B,GAAG,GAAG;;AAEvC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,UAAU,EACVC,QAAQ,EACRC,WAAW,GAAG,UAAU,EACxBC,OAAO,GAAG,CAAC,CAAC,EACX;EACD,MAAMC,YAAY,GACjBF,WAAW,K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AC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useDispatch","useSelect","useRegistry","useCallback","useState","useThrottle","__experimentalUseDropZone","useDropZone","isRTL","isUnmodifiedDefaultBlock","getIsUnmodifiedDefaultBlock","store","blocksStore","useOnBlockDrop","getDistanceToNearestEdge","isPointContainedByRect","isPointWithinTopAndBottomBoundariesOfRect","blockEditorStore","unlock","THRESHOLD_DISTANCE","MINIMUM_HEIGHT_FOR_THRESHOLD","MINIMUM_WIDTH_FOR_THRESHOLD","getDropTargetPosition","blocksData","position","orientation","options","allowedEdges","nearestIndex","insertPosition","minDistance","Infinity","targetBlockIndex","nearestSide","dropZoneElement","parentBlockOrientation","rootBlockIndex","rect","getBoundingClientRect","distance","edge","height","isRightToLeft","width","forEach","blockIndex","blockOrientation","sideDistance","sideEdge","isPointInsideRect","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","isDropTargetValid","getBlockType","allowedBlocks","draggedBlockNames","targetBlockName","areBlocksAllowed","allowedBlockNames","map","name","every","includes","draggedBlockTypes","targetMatchesDraggedBlockParents","block","allowedParentName","parent","isInsertionPoint","targetToCheck","ownerDocument","defaultView","HTMLElement","closest","useBlockDropZone","rootClientId","targetRootClientId","parentClientId","parentBlockClientId","isDisabled","registry","dropTarget","setDropTarget","index","operation","getBlockVariations","getGroupingBlockName","canInsertBlockType","getBlockListSettings","getBlocks","getBlockIndex","getDraggedBlockClientIds","getBlockNamesByClientId","getAllowedBlocks","isDragging","isGroupable","isZoomOut","getSectionRootClientId","getBlockParents","showInsertionPoint","hideInsertionPoint","startDragging","stopDragging","onBlockDrop","throttled","event","draggedBlockClientIds","targetParents","isTargetWithinDraggedBlocks","some","clientId","isBlockDroppingAllowed","sectionRootClientId","blocks","length","batch","getElementById","dropTargetPosition","x","clientX","y","clientY","undefined","targetIndex","targetBlock","areAllImages","canInsertGalleryBlock","areGroupableBlocks","groupBlockVariations","canInsertRow","find","insertionPointClientId","onDrop","onDragOver","currentTarget","onDragLeave","relatedTarget","target","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.closest( '[data-is-insertion-point]' )\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOut,\n\t\tgetSectionRootClientId,\n\t\tgetBlockParents,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\n\t\t\t\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\t\t\t\tconst targetParents = [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\t...getBlockParents( targetRootClientId, true ),\n\t\t\t\t];\n\n\t\t\t\t// Check if the target is within any of the dragged blocks.\n\t\t\t\tconst isTargetWithinDraggedBlocks = draggedBlockClientIds.some(\n\t\t\t\t\t( clientId ) => targetParents.includes( clientId )\n\t\t\t\t);\n\n\t\t\t\tif ( isTargetWithinDraggedBlocks ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tdraggedBlockClientIds\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tif ( isZoomOut() && operation !== 'insert' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACrE,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;AAC1D,SACCC,WAAW,EACXC,yBAAyB,IAAIC,WAAW,QAClC,oBAAoB;AAC3B,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SACCC,wBAAwB,IAAIC,2BAA2B,EACvDC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,OAAOC,cAAc,MAAM,sBAAsB;AACjD,SACCC,wBAAwB,EACxBC,sBAAsB,EACtBC,yCAAyC,QACnC,kBAAkB;AACzB,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,aAAa;AACvD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,4BAA4B,GAAG,GAAG;AACxC,MAAMC,2BAA2B,GAAG,GAAG;;AAEvC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,UAAU,EACVC,QAAQ,EACRC,WAAW,GAAG,UAAU,EACxBC,OAAO,GAAG,CAAC,CAAC,EACX;EACD,MAAMC,YAAY,GACjBF,WAAW,KAAK,YAAY,GACzB,CAAE,MAAM,EAAE,OAAO,CAAE,GACnB,CAAE,KAAK,EAAE,QAAQ,CAAE;EAEvB,IAAIG,YAAY,GAAG,CA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AAS,CAACkC,MAAM,CAAC,CAAC;MAClBtC,kBAAkB,CAAC,CAAC;IACrB,CAAC;IACDuC,SAASA,CAAA,EAAG;MACXnC,SAAS,CAACkC,MAAM,CAAC,CAAC;MAClBpC,YAAY,CAAC,CAAC;MACdF,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -53,7 +53,8 @@ function useMovingAnimation({
|
|
|
53
53
|
isBlockSelected,
|
|
54
54
|
isFirstMultiSelectedBlock,
|
|
55
55
|
isBlockMultiSelected,
|
|
56
|
-
isAncestorMultiSelected
|
|
56
|
+
isAncestorMultiSelected,
|
|
57
|
+
isDraggingBlocks
|
|
57
58
|
} = useSelect(blockEditorStore);
|
|
58
59
|
|
|
59
60
|
// Whenever the trigger changes, we need to take a snapshot of the current
|
|
@@ -72,7 +73,12 @@ function useMovingAnimation({
|
|
|
72
73
|
const scrollContainer = getScrollContainer(ref.current);
|
|
73
74
|
const isSelected = isBlockSelected(clientId);
|
|
74
75
|
const adjustScrolling = isSelected || isFirstMultiSelectedBlock(clientId);
|
|
76
|
+
const isDragging = isDraggingBlocks();
|
|
75
77
|
function preserveScrollPosition() {
|
|
78
|
+
// The user already scrolled when dragging blocks.
|
|
79
|
+
if (isDragging) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
if (adjustScrolling && prevRect) {
|
|
77
83
|
const blockRect = ref.current.getBoundingClientRect();
|
|
78
84
|
const diff = blockRect.top - prevRect.top;
|
|
@@ -96,6 +102,13 @@ function useMovingAnimation({
|
|
|
96
102
|
return;
|
|
97
103
|
}
|
|
98
104
|
const isPartOfSelection = isSelected || isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId);
|
|
105
|
+
|
|
106
|
+
// The user already dragged the blocks to the new position, so don't
|
|
107
|
+
// animate the dragged blocks.
|
|
108
|
+
if (isPartOfSelection && isDragging) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
99
112
|
// Make sure the other blocks move under the selected block(s).
|
|
100
113
|
const zIndex = isPartOfSelection ? '1' : '';
|
|
101
114
|
const controller = new Controller({
|
|
@@ -145,7 +158,7 @@ function useMovingAnimation({
|
|
|
145
158
|
y: 0
|
|
146
159
|
});
|
|
147
160
|
};
|
|
148
|
-
}, [previous, prevRect, clientId, isTyping, getGlobalBlockCount, isBlockSelected, isFirstMultiSelectedBlock, isBlockMultiSelected, isAncestorMultiSelected]);
|
|
161
|
+
}, [previous, prevRect, clientId, isTyping, getGlobalBlockCount, isBlockSelected, isFirstMultiSelectedBlock, isBlockMultiSelected, isAncestorMultiSelected, isDraggingBlocks]);
|
|
149
162
|
return ref;
|
|
150
163
|
}
|
|
151
164
|
export default useMovingAnimation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Controller","useLayoutEffect","useMemo","useRef","getScrollContainer","useSelect","store","blockEditorStore","BLOCK_ANIMATION_THRESHOLD","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","triggerAnimationOnChange","clientId","ref","isTyping","getGlobalBlockCount","isBlockSelected","isFirstMultiSelectedBlock","isBlockMultiSelected","isAncestorMultiSelected","previous","prevRect","current","getBoundingClientRect","scrollContainer","isSelected","adjustScrolling","preserveScrollPosition","blockRect","diff","scrollTop","disableAnimation","window","matchMedia","matches","isPartOfSelection","zIndex","controller","x","y","config","mass","tension","friction","onChange","value","Math","round","finishedMoving","style","transformOrigin","transform","undefined","destination","start","from","stop","set"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Controller } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useRef } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\nfunction getAbsolutePosition( element ) {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n}\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n * @param {string} $1.clientId\n */\nfunction useMovingAnimation( { triggerAnimationOnChange, clientId } ) {\n\tconst ref = useRef();\n\tconst {\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t} = useSelect( blockEditorStore );\n\n\t// Whenever the trigger changes, we need to take a snapshot of the current\n\t// position of the block to use it as a destination point for the animation.\n\tconst { previous, prevRect } = useMemo(\n\t\t() => ( {\n\t\t\tprevious: ref.current && getAbsolutePosition( ref.current ),\n\t\t\tprevRect: ref.current && ref.current.getBoundingClientRect(),\n\t\t} ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous || ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\t\tconst isSelected = isBlockSelected( clientId );\n\t\tconst adjustScrolling =\n\t\t\tisSelected || isFirstMultiSelectedBlock( clientId );\n\n\t\tfunction preserveScrollPosition() {\n\t\t\tif ( adjustScrolling && prevRect ) {\n\t\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\t\tif ( diff ) {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We disable the animation if the user has a preference for reduced\n\t\t// motion, if the user is typing (insertion by Enter), or if the block\n\t\t// count exceeds the threshold (insertion caused all the blocks that\n\t\t// follow to animate).\n\t\t// To do: consider enableing the _moving_ animation even for large\n\t\t// posts, while only disabling the _insertion_ animation?\n\t\tconst disableAnimation =\n\t\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||\n\t\t\tisTyping() ||\n\t\t\tgetGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;\n\n\t\tif ( disableAnimation ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPartOfSelection =\n\t\t\tisSelected ||\n\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\tisAncestorMultiSelected( clientId );\n\t\t// Make sure the other blocks move under the selected block(s).\n\t\tconst zIndex = isPartOfSelection ? '1' : '';\n\n\t\tconst controller = new Controller( {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\t\tonChange( { value } ) {\n\t\t\t\tif ( ! ref.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet { x, y } = value;\n\t\t\t\tx = Math.round( x );\n\t\t\t\ty = Math.round( y );\n\t\t\t\tconst finishedMoving = x === 0 && y === 0;\n\t\t\t\tref.current.style.transformOrigin = 'center center';\n\t\t\t\tref.current.style.transform = finishedMoving\n\t\t\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\t\t\tref.current.style.zIndex = zIndex;\n\t\t\t\tpreserveScrollPosition();\n\t\t\t},\n\t\t} );\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\tconst x = Math.round( previous.left - destination.left );\n\t\tconst y = Math.round( previous.top - destination.top );\n\n\t\tcontroller.start( { x: 0, y: 0, from: { x, y } } );\n\n\t\treturn () => {\n\t\t\tcontroller.stop();\n\t\t\tcontroller.set( { x: 0, y: 0 } );\n\t\t};\n\t}, [\n\t\tprevious,\n\t\tprevRect,\n\t\tclientId,\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t] );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACrE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,GAAG;AAErC,SAASC,mBAAmBA,CAAEC,OAAO,EAAG;EACvC,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAAEC,wBAAwB;EAAEC;AAAS,CAAC,EAAG;EACrE,MAAMC,GAAG,GAAGf,MAAM,CAAC,CAAC;EACpB,MAAM;IACLgB,QAAQ;IACRC,mBAAmB;IACnBC,eAAe;IACfC,yBAAyB;IACzBC,oBAAoB;IACpBC;EACD,CAAC,GAAGnB,SAAS,CAAEE,gBAAiB,CAAC;;EAEjC;EACA;EACA,MAAM;IAAEkB,QAAQ;IAAEC;EAAS,CAAC,GAAGxB,OAAO,CACrC,OAAQ;IACPuB,QAAQ,EA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;MAAEhB,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEgB,IAAI,EAAE;QAAEjB,CAAC;QAAEC;MAAE;IAAE,CAAE,CAAC;IAElD,OAAO,MAAM;MACZF,UAAU,CAACmB,IAAI,CAAC,CAAC;MACjBnB,UAAU,CAACoB,GAAG,CAAE;QAAEnB,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE;MAAE,CAAE,CAAC;IACjC,CAAC;EACF,CAAC,EAAE,CACFnB,QAAQ,EACRC,QAAQ,EACRT,QAAQ,EACRE,QAAQ,EACRC,mBAAmB,EACnBC,eAAe,EACfC,yBAAyB,EACzBC,oBAAoB,EACpBC,uBAAuB,CACtB,CAAC;EAEH,OAAON,GAAG;AACX;AAEA,eAAeH,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Controller","useLayoutEffect","useMemo","useRef","getScrollContainer","useSelect","store","blockEditorStore","BLOCK_ANIMATION_THRESHOLD","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","triggerAnimationOnChange","clientId","ref","isTyping","getGlobalBlockCount","isBlockSelected","isFirstMultiSelectedBlock","isBlockMultiSelected","isAncestorMultiSelected","isDraggingBlocks","previous","prevRect","current","getBoundingClientRect","scrollContainer","isSelected","adjustScrolling","isDragging","preserveScrollPosition","blockRect","diff","scrollTop","disableAnimation","window","matchMedia","matches","isPartOfSelection","zIndex","controller","x","y","config","mass","tension","friction","onChange","value","Math","round","finishedMoving","style","transformOrigin","transform","undefined","destination","start","from","stop","set"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Controller } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useRef } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\nfunction getAbsolutePosition( element ) {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n}\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n * @param {string} $1.clientId\n */\nfunction useMovingAnimation( { triggerAnimationOnChange, clientId } ) {\n\tconst ref = useRef();\n\tconst {\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t\tisDraggingBlocks,\n\t} = useSelect( blockEditorStore );\n\n\t// Whenever the trigger changes, we need to take a snapshot of the current\n\t// position of the block to use it as a destination point for the animation.\n\tconst { previous, prevRect } = useMemo(\n\t\t() => ( {\n\t\t\tprevious: ref.current && getAbsolutePosition( ref.current ),\n\t\t\tprevRect: ref.current && ref.current.getBoundingClientRect(),\n\t\t} ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous || ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\t\tconst isSelected = isBlockSelected( clientId );\n\t\tconst adjustScrolling =\n\t\t\tisSelected || isFirstMultiSelectedBlock( clientId );\n\t\tconst isDragging = isDraggingBlocks();\n\n\t\tfunction preserveScrollPosition() {\n\t\t\t// The user already scrolled when dragging blocks.\n\t\t\tif ( isDragging ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( adjustScrolling && prevRect ) {\n\t\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\t\tif ( diff ) {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We disable the animation if the user has a preference for reduced\n\t\t// motion, if the user is typing (insertion by Enter), or if the block\n\t\t// count exceeds the threshold (insertion caused all the blocks that\n\t\t// follow to animate).\n\t\t// To do: consider enableing the _moving_ animation even for large\n\t\t// posts, while only disabling the _insertion_ animation?\n\t\tconst disableAnimation =\n\t\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||\n\t\t\tisTyping() ||\n\t\t\tgetGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;\n\n\t\tif ( disableAnimation ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPartOfSelection =\n\t\t\tisSelected ||\n\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\tisAncestorMultiSelected( clientId );\n\n\t\t// The user already dragged the blocks to the new position, so don't\n\t\t// animate the dragged blocks.\n\t\tif ( isPartOfSelection && isDragging ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure the other blocks move under the selected block(s).\n\t\tconst zIndex = isPartOfSelection ? '1' : '';\n\n\t\tconst controller = new Controller( {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\t\tonChange( { value } ) {\n\t\t\t\tif ( ! ref.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet { x, y } = value;\n\t\t\t\tx = Math.round( x );\n\t\t\t\ty = Math.round( y );\n\t\t\t\tconst finishedMoving = x === 0 && y === 0;\n\t\t\t\tref.current.style.transformOrigin = 'center center';\n\t\t\t\tref.current.style.transform = finishedMoving\n\t\t\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\t\t\tref.current.style.zIndex = zIndex;\n\t\t\t\tpreserveScrollPosition();\n\t\t\t},\n\t\t} );\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\tconst x = Math.round( previous.left - destination.left );\n\t\tconst y = Math.round( previous.top - destination.top );\n\n\t\tcontroller.start( { x: 0, y: 0, from: { x, y } } );\n\n\t\treturn () => {\n\t\t\tcontroller.stop();\n\t\t\tcontroller.set( { x: 0, y: 0 } );\n\t\t};\n\t}, [\n\t\tprevious,\n\t\tprevRect,\n\t\tclientId,\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t\tisDraggingBlocks,\n\t] );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACrE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,GAAG;AAErC,SAASC,mBAAmBA,CAAEC,OAAO,EAAG;EACvC,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAAEC,wBAAwB;EAAEC;AAAS,CAAC,EAAG;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