@wordpress/block-editor 15.8.1-next.dc3f6d3c1.0 → 15.9.1-next.8b30e05b0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +4 -0
- package/build/components/block-list/index.js +2 -1
- package/build/components/block-list/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build/components/block-lock/modal.js +5 -5
- package/build/components/block-lock/modal.js.map +2 -2
- package/build/components/block-lock/use-block-lock.js +10 -13
- package/build/components/block-lock/use-block-lock.js.map +2 -2
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
- package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build/components/content-only-controls/index.js +225 -44
- package/build/components/content-only-controls/index.js.map +3 -3
- package/build/components/content-only-controls/link/index.js +92 -103
- package/build/components/content-only-controls/link/index.js.map +3 -3
- package/build/components/content-only-controls/media/index.js +134 -134
- package/build/components/content-only-controls/media/index.js.map +3 -3
- package/build/components/content-only-controls/rich-text/index.js +65 -74
- package/build/components/content-only-controls/rich-text/index.js.map +3 -3
- package/build/components/font-family/index.js +1 -15
- package/build/components/font-family/index.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +35 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +1 -2
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/index.js +3 -0
- package/build/components/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build/components/link-control/index.js +15 -7
- package/build/components/link-control/index.js.map +2 -2
- package/build/components/list-view/block-select-button.js +3 -11
- package/build/components/list-view/block-select-button.js.map +2 -2
- package/build/components/list-view/block.js +9 -7
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/media-placeholder/index.js +17 -4
- package/build/components/media-placeholder/index.js.map +2 -2
- package/build/components/media-placeholder/utils.js +60 -0
- package/build/components/media-placeholder/utils.js.map +7 -0
- package/build/components/media-replace-flow/index.js +20 -3
- package/build/components/media-replace-flow/index.js.map +2 -2
- package/build/components/tool-selector/index.js +46 -0
- package/build/components/tool-selector/index.js.map +7 -0
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/dimensions.js +3 -3
- package/build/hooks/dimensions.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/store/private-selectors.js +43 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +2 -1
- package/build/store/reducer.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -1
- package/build-module/components/block-list/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build-module/components/block-lock/modal.js +5 -5
- package/build-module/components/block-lock/modal.js.map +2 -2
- package/build-module/components/block-lock/use-block-lock.js +10 -13
- package/build-module/components/block-lock/use-block-lock.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
- package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build-module/components/content-only-controls/index.js +229 -46
- package/build-module/components/content-only-controls/index.js.map +2 -2
- package/build-module/components/content-only-controls/link/index.js +92 -104
- package/build-module/components/content-only-controls/link/index.js.map +2 -2
- package/build-module/components/content-only-controls/media/index.js +134 -135
- package/build-module/components/content-only-controls/media/index.js.map +2 -2
- package/build-module/components/content-only-controls/rich-text/index.js +67 -81
- package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
- package/build-module/components/font-family/index.js +1 -15
- package/build-module/components/font-family/index.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +35 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build-module/components/link-control/index.js +16 -8
- package/build-module/components/link-control/index.js.map +2 -2
- package/build-module/components/list-view/block-select-button.js +3 -11
- package/build-module/components/list-view/block-select-button.js.map +2 -2
- package/build-module/components/list-view/block.js +9 -7
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +18 -5
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-placeholder/utils.js +35 -0
- package/build-module/components/media-placeholder/utils.js.map +7 -0
- package/build-module/components/media-replace-flow/index.js +20 -3
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/tool-selector/index.js +15 -0
- package/build-module/components/tool-selector/index.js.map +7 -0
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/dimensions.js +3 -3
- package/build-module/hooks/dimensions.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/store/private-selectors.js +39 -3
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +2 -1
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +2 -2
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +14 -5
- package/build-style/style.css +14 -5
- package/package.json +38 -37
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-list/index.js +3 -1
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
- package/src/components/block-lock/modal.js +6 -5
- package/src/components/block-lock/use-block-lock.js +10 -14
- package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
- package/src/components/block-settings-menu-controls/index.js +1 -1
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +314 -50
- package/src/components/content-only-controls/link/index.js +62 -57
- package/src/components/content-only-controls/media/index.js +177 -156
- package/src/components/content-only-controls/rich-text/index.js +30 -44
- package/src/components/content-only-controls/styles.scss +10 -1
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +1 -16
- package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
- package/src/components/global-styles/dimensions-panel.js +36 -0
- package/src/components/global-styles/hooks.js +1 -1
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/index.js +4 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
- package/src/components/link-control/index.js +36 -12
- package/src/components/list-view/block-select-button.js +22 -30
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +20 -5
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
- package/src/components/media-placeholder/utils.js +65 -0
- package/src/components/media-replace-flow/index.js +22 -3
- package/src/components/tool-selector/index.js +19 -0
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/dimensions.js +8 -3
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/hooks/utils.js +4 -0
- package/src/store/private-selectors.js +123 -6
- package/src/store/reducer.js +3 -0
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/store/test/reducer.js +17 -7
- package/src/style.scss +0 -1
- package/tsconfig.json +1 -0
- package/build/components/content-only-controls/plain-text/index.js +0 -68
- package/build/components/content-only-controls/plain-text/index.js.map +0 -7
- package/build-module/components/content-only-controls/plain-text/index.js +0 -50
- package/build-module/components/content-only-controls/plain-text/index.js.map +0 -7
- package/src/components/content-only-controls/plain-text/index.js +0 -49
- package/src/components/font-family/style.scss +0 -7
- /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
- /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
- /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -847,6 +847,10 @@ _Related_
|
|
|
847
847
|
|
|
848
848
|
- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore>
|
|
849
849
|
|
|
850
|
+
### ToolSelector
|
|
851
|
+
|
|
852
|
+
This component has been deprecated and no longer renders anything.
|
|
853
|
+
|
|
850
854
|
### transformStyles
|
|
851
855
|
|
|
852
856
|
Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
|
|
@@ -201,6 +201,7 @@ function Items({
|
|
|
201
201
|
rootClientId
|
|
202
202
|
));
|
|
203
203
|
const hasSelectedRoot = !!(rootClientId && selectedBlockClientId && rootClientId === selectedBlockClientId);
|
|
204
|
+
const templateLock = getTemplateLock(rootClientId);
|
|
204
205
|
return {
|
|
205
206
|
order: _order,
|
|
206
207
|
selectedBlocks: selectedBlockClientIds,
|
|
@@ -209,7 +210,7 @@ function Items({
|
|
|
209
210
|
shouldRenderAppender: (!isSectionBlock(rootClientId) || isContainerInsertableToInContentOnlyMode(
|
|
210
211
|
getBlockName(selectedBlockClientId),
|
|
211
212
|
rootClientId
|
|
212
|
-
)) && getBlockEditingMode(rootClientId) !== "disabled" && !
|
|
213
|
+
)) && getBlockEditingMode(rootClientId) !== "disabled" && (!templateLock || templateLock === "contentOnly") && hasAppender && !_isZoomOut() && (hasCustomAppender || hasSelectedRoot || showRootAppender)
|
|
213
214
|
};
|
|
214
215
|
},
|
|
215
216
|
[rootClientId, hasAppender, hasCustomAppender]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-list/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAsyncModeProvider,\n\tuseSelect,\n\tuseDispatch,\n\tuseRegistry,\n} from '@wordpress/data';\nimport { useMergeRefs, useDebounce } from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseEffect,\n\tuseMemo,\n\tuseCallback,\n} from '@wordpress/element';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useInnerBlocksProps } from '../inner-blocks';\nimport {\n\tBlockEditContextProvider,\n\tDEFAULT_BLOCK_EDIT_CONTEXT,\n} from '../block-edit/context';\nimport { useTypingObserver } from '../observe-typing';\nimport { ZoomOutSeparator } from './zoom-out-separator';\nimport { unlock } from '../../lock-unlock';\n\nexport const IntersectionObserver = createContext();\nIntersectionObserver.displayName = 'IntersectionObserverContext';\n\nconst pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();\nconst delayedBlockVisibilityDebounceOptions = {\n\ttrailing: true,\n};\n\nfunction Root( { className, ...settings } ) {\n\tconst { isOutlineMode, isFocusMode, editedContentOnlySection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tisTyping,\n\t\t\t\thasBlockSpotlight,\n\t\t\t\tgetEditedContentOnlySection,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode && ! isTyping(),\n\t\t\t\tisFocusMode: focusMode || hasBlockSpotlight(),\n\t\t\t\teditedContentOnlySection: getEditedContentOnlySection(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst registry = useRegistry();\n\tconst { setBlockVisibility } = useDispatch( blockEditorStore );\n\n\tconst delayedBlockVisibilityUpdates = useDebounce(\n\t\tuseCallback( () => {\n\t\t\tconst updates = {};\n\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t.get( registry )\n\t\t\t\t.forEach( ( [ id, isIntersecting ] ) => {\n\t\t\t\t\tupdates[ id ] = isIntersecting;\n\t\t\t\t} );\n\t\t\tsetBlockVisibility( updates );\n\t\t}, [ registry ] ),\n\t\t300,\n\t\tdelayedBlockVisibilityDebounceOptions\n\t);\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tif ( ! pendingBlockVisibilityUpdatesPerRegistry.get( registry ) ) {\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry.set( registry, [] );\n\t\t\t}\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t\t.get( registry )\n\t\t\t\t\t.push( [ clientId, entry.isIntersecting ] );\n\t\t\t}\n\t\t\tdelayedBlockVisibilityUpdates();\n\t\t} );\n\t}, [] );\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tref: useMergeRefs( [\n\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\tuseInBetweenInserter(),\n\t\t\t\tuseTypingObserver(),\n\t\t\t] ),\n\t\t\tclassName: clsx( 'is-root-container', className, {\n\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t'is-focus-mode': isFocusMode,\n\t\t\t} ),\n\t\t},\n\t\tsettings\n\t);\n\treturn (\n\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t\t{ !! editedContentOnlySection && (\n\t\t\t\t<StopEditingContentOnlySectionOnOutsideSelect\n\t\t\t\t\tclientId={ editedContentOnlySection }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</IntersectionObserver.Provider>\n\t);\n}\n\nfunction StopEditingContentOnlySectionOnOutsideSelect( { clientId } ) {\n\tconst { stopEditingContentOnlySection } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isBlockOrDescendantSelected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockSelectionStart,\n\t\t\t} = select( blockEditorStore );\n\t\t\treturn (\n\t\t\t\t! getBlockSelectionStart() ||\n\t\t\t\tisBlockSelected( clientId ) ||\n\t\t\t\thasSelectedInnerBlock( clientId, true )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isBlockOrDescendantSelected ) {\n\t\t\tstopEditingContentOnlySection();\n\t\t}\n\t}, [ isBlockOrDescendantSelected, stopEditingContentOnlySection ] );\n\n\treturn null;\n}\n\nexport default function BlockList( settings ) {\n\treturn (\n\t\t<BlockEditContextProvider value={ DEFAULT_BLOCK_EDIT_CONTEXT }>\n\t\t\t<Root { ...settings } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n\nconst EMPTY_ARRAY = [];\nconst EMPTY_SET = new Set();\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender: CustomAppender,\n\t__experimentalAppenderTagName,\n\tlayout = defaultLayout,\n} ) {\n\t// Avoid passing CustomAppender to useSelect because it could be a new\n\t// function on every render.\n\tconst hasAppender = CustomAppender !== false;\n\tconst hasCustomAppender = !! CustomAppender;\n\tconst {\n\t\torder,\n\t\tisZoomOut,\n\t\tselectedBlocks,\n\t\tvisibleBlocks,\n\t\tshouldRenderAppender,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetVisibleBlocks,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tisSectionBlock,\n\t\t\t\tisContainerInsertableToInContentOnlyMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisZoomOut: _isZoomOut,\n\t\t\t\tcanInsertBlockType,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tconst _order = getBlockOrder( rootClientId );\n\n\t\t\tif ( getSettings().isPreviewMode ) {\n\t\t\t\treturn {\n\t\t\t\t\torder: _order,\n\t\t\t\t\tselectedBlocks: EMPTY_ARRAY,\n\t\t\t\t\tvisibleBlocks: EMPTY_SET,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst showRootAppender =\n\t\t\t\t! rootClientId &&\n\t\t\t\t! selectedBlockClientId &&\n\t\t\t\t( ! _order.length ||\n\t\t\t\t\t! canInsertBlockType(\n\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t) );\n\t\t\tconst hasSelectedRoot = !! (\n\t\t\t\trootClientId &&\n\t\t\t\tselectedBlockClientId &&\n\t\t\t\trootClientId === selectedBlockClientId\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\torder: _order,\n\t\t\t\tselectedBlocks: selectedBlockClientIds,\n\t\t\t\tvisibleBlocks: __unstableGetVisibleBlocks(),\n\t\t\t\tisZoomOut: _isZoomOut(),\n\t\t\t\tshouldRenderAppender:\n\t\t\t\t\t( ! isSectionBlock( rootClientId ) ||\n\t\t\t\t\t\tisContainerInsertableToInContentOnlyMode(\n\t\t\t\t\t\t\tgetBlockName( selectedBlockClientId ),\n\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t) ) &&\n\t\t\t\t\tgetBlockEditingMode( rootClientId ) !== 'disabled' &&\n\t\t\t\t\t!
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAKO;AACP,qBAA0C;AAC1C,qBAKO;AACP,oBAAoC;AAKpC,mBAA2B;AAC3B,iCAA8B;AAC9B,qCAAqC;AACrC,mBAA0C;AAC1C,oBAA8C;AAC9C,qCAAyC;AACzC,0BAAoC;AACpC,qBAGO;AACP,4BAAkC;AAClC,gCAAiC;AACjC,yBAAuB;AA+ErB;AA7EK,IAAM,2BAAuB,8BAAc;AAClD,qBAAqB,cAAc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f;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA,SAAS;AACV,GAAI;AAGH,QAAM,cAAc,mBAAmB;AACvC,QAAM,oBAAoB,CAAC,CAAE;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,MACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AAEvC,YAAM,SAAS,cAAe,YAAa;AAE3C,UAAK,YAAY,EAAE,eAAgB;AAClC,eAAO;AAAA,UACN,OAAO;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe;AAAA,QAChB;AAAA,MACD;AAEA,YAAM,yBAAyB,0BAA0B;AACzD,YAAM,wBAAwB,uBAAwB,CAAE;AACxD,YAAM,mBACL,CAAE,gBACF,CAAE,0BACA,CAAE,OAAO,UACV,CAAE;AAAA,YACD,mCAAoB;AAAA,QACpB;AAAA,MACD;AACF,YAAM,kBAAkB,CAAC,EACxB,gBACA,yBACA,iBAAiB;AAGlB,aAAO;AAAA,QACN,OAAO;AAAA,QACP,gBAAgB;AAAA,QAChB,eAAe,2BAA2B;AAAA,QAC1C,WAAW,WAAW;AAAA,QACtB,uBACG,CAAE,eAAgB,YAAa,KAChC;AAAA,UACC,aAAc,qBAAsB;AAAA,UACpC;AAAA,QACD,MACD,oBAAqB,YAAa,MAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAsyncModeProvider,\n\tuseSelect,\n\tuseDispatch,\n\tuseRegistry,\n} from '@wordpress/data';\nimport { useMergeRefs, useDebounce } from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseEffect,\n\tuseMemo,\n\tuseCallback,\n} from '@wordpress/element';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useInnerBlocksProps } from '../inner-blocks';\nimport {\n\tBlockEditContextProvider,\n\tDEFAULT_BLOCK_EDIT_CONTEXT,\n} from '../block-edit/context';\nimport { useTypingObserver } from '../observe-typing';\nimport { ZoomOutSeparator } from './zoom-out-separator';\nimport { unlock } from '../../lock-unlock';\n\nexport const IntersectionObserver = createContext();\nIntersectionObserver.displayName = 'IntersectionObserverContext';\n\nconst pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();\nconst delayedBlockVisibilityDebounceOptions = {\n\ttrailing: true,\n};\n\nfunction Root( { className, ...settings } ) {\n\tconst { isOutlineMode, isFocusMode, editedContentOnlySection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tisTyping,\n\t\t\t\thasBlockSpotlight,\n\t\t\t\tgetEditedContentOnlySection,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode && ! isTyping(),\n\t\t\t\tisFocusMode: focusMode || hasBlockSpotlight(),\n\t\t\t\teditedContentOnlySection: getEditedContentOnlySection(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst registry = useRegistry();\n\tconst { setBlockVisibility } = useDispatch( blockEditorStore );\n\n\tconst delayedBlockVisibilityUpdates = useDebounce(\n\t\tuseCallback( () => {\n\t\t\tconst updates = {};\n\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t.get( registry )\n\t\t\t\t.forEach( ( [ id, isIntersecting ] ) => {\n\t\t\t\t\tupdates[ id ] = isIntersecting;\n\t\t\t\t} );\n\t\t\tsetBlockVisibility( updates );\n\t\t}, [ registry ] ),\n\t\t300,\n\t\tdelayedBlockVisibilityDebounceOptions\n\t);\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tif ( ! pendingBlockVisibilityUpdatesPerRegistry.get( registry ) ) {\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry.set( registry, [] );\n\t\t\t}\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\tpendingBlockVisibilityUpdatesPerRegistry\n\t\t\t\t\t.get( registry )\n\t\t\t\t\t.push( [ clientId, entry.isIntersecting ] );\n\t\t\t}\n\t\t\tdelayedBlockVisibilityUpdates();\n\t\t} );\n\t}, [] );\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tref: useMergeRefs( [\n\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\tuseInBetweenInserter(),\n\t\t\t\tuseTypingObserver(),\n\t\t\t] ),\n\t\t\tclassName: clsx( 'is-root-container', className, {\n\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t'is-focus-mode': isFocusMode,\n\t\t\t} ),\n\t\t},\n\t\tsettings\n\t);\n\treturn (\n\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t\t{ !! editedContentOnlySection && (\n\t\t\t\t<StopEditingContentOnlySectionOnOutsideSelect\n\t\t\t\t\tclientId={ editedContentOnlySection }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</IntersectionObserver.Provider>\n\t);\n}\n\nfunction StopEditingContentOnlySectionOnOutsideSelect( { clientId } ) {\n\tconst { stopEditingContentOnlySection } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isBlockOrDescendantSelected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockSelectionStart,\n\t\t\t} = select( blockEditorStore );\n\t\t\treturn (\n\t\t\t\t! getBlockSelectionStart() ||\n\t\t\t\tisBlockSelected( clientId ) ||\n\t\t\t\thasSelectedInnerBlock( clientId, true )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isBlockOrDescendantSelected ) {\n\t\t\tstopEditingContentOnlySection();\n\t\t}\n\t}, [ isBlockOrDescendantSelected, stopEditingContentOnlySection ] );\n\n\treturn null;\n}\n\nexport default function BlockList( settings ) {\n\treturn (\n\t\t<BlockEditContextProvider value={ DEFAULT_BLOCK_EDIT_CONTEXT }>\n\t\t\t<Root { ...settings } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n\nconst EMPTY_ARRAY = [];\nconst EMPTY_SET = new Set();\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender: CustomAppender,\n\t__experimentalAppenderTagName,\n\tlayout = defaultLayout,\n} ) {\n\t// Avoid passing CustomAppender to useSelect because it could be a new\n\t// function on every render.\n\tconst hasAppender = CustomAppender !== false;\n\tconst hasCustomAppender = !! CustomAppender;\n\tconst {\n\t\torder,\n\t\tisZoomOut,\n\t\tselectedBlocks,\n\t\tvisibleBlocks,\n\t\tshouldRenderAppender,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetVisibleBlocks,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tisSectionBlock,\n\t\t\t\tisContainerInsertableToInContentOnlyMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisZoomOut: _isZoomOut,\n\t\t\t\tcanInsertBlockType,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tconst _order = getBlockOrder( rootClientId );\n\n\t\t\tif ( getSettings().isPreviewMode ) {\n\t\t\t\treturn {\n\t\t\t\t\torder: _order,\n\t\t\t\t\tselectedBlocks: EMPTY_ARRAY,\n\t\t\t\t\tvisibleBlocks: EMPTY_SET,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst showRootAppender =\n\t\t\t\t! rootClientId &&\n\t\t\t\t! selectedBlockClientId &&\n\t\t\t\t( ! _order.length ||\n\t\t\t\t\t! canInsertBlockType(\n\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t) );\n\t\t\tconst hasSelectedRoot = !! (\n\t\t\t\trootClientId &&\n\t\t\t\tselectedBlockClientId &&\n\t\t\t\trootClientId === selectedBlockClientId\n\t\t\t);\n\n\t\t\tconst templateLock = getTemplateLock( rootClientId );\n\n\t\t\treturn {\n\t\t\t\torder: _order,\n\t\t\t\tselectedBlocks: selectedBlockClientIds,\n\t\t\t\tvisibleBlocks: __unstableGetVisibleBlocks(),\n\t\t\t\tisZoomOut: _isZoomOut(),\n\t\t\t\tshouldRenderAppender:\n\t\t\t\t\t( ! isSectionBlock( rootClientId ) ||\n\t\t\t\t\t\tisContainerInsertableToInContentOnlyMode(\n\t\t\t\t\t\t\tgetBlockName( selectedBlockClientId ),\n\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t) ) &&\n\t\t\t\t\tgetBlockEditingMode( rootClientId ) !== 'disabled' &&\n\t\t\t\t\t( ! templateLock || templateLock === 'contentOnly' ) &&\n\t\t\t\t\thasAppender &&\n\t\t\t\t\t! _isZoomOut() &&\n\t\t\t\t\t( hasCustomAppender ||\n\t\t\t\t\t\thasSelectedRoot ||\n\t\t\t\t\t\tshowRootAppender ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, hasAppender, hasCustomAppender ]\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t{ order.map( ( clientId ) => (\n\t\t\t\t<AsyncModeProvider\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// Only provide data asynchronously if the block is\n\t\t\t\t\t\t// not visible and not selected.\n\t\t\t\t\t\t! visibleBlocks.has( clientId ) &&\n\t\t\t\t\t\t! selectedBlocks.includes( clientId )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isZoomOut && (\n\t\t\t\t\t\t<ZoomOutSeparator\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tposition=\"top\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isZoomOut && (\n\t\t\t\t\t\t<ZoomOutSeparator\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</AsyncModeProvider>\n\t\t\t) ) }\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t{ shouldRenderAppender && (\n\t\t\t\t<BlockListAppender\n\t\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tCustomAppender={ CustomAppender }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</LayoutProvider>\n\t);\n}\n\nexport function BlockListItems( props ) {\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<AsyncModeProvider value={ false }>\n\t\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|
@@ -33,15 +33,20 @@ function isColorTransparent(color) {
|
|
|
33
33
|
return !color || color === "transparent" || color === "rgba(0, 0, 0, 0)";
|
|
34
34
|
}
|
|
35
35
|
function useEventHandlers({ clientId, isSelected }) {
|
|
36
|
-
const {
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const {
|
|
37
|
+
getBlockRootClientId,
|
|
38
|
+
isZoomOut,
|
|
39
|
+
hasMultiSelection,
|
|
40
|
+
isSectionBlock,
|
|
41
|
+
editedContentOnlySection
|
|
42
|
+
} = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store));
|
|
39
43
|
const {
|
|
40
44
|
insertAfterBlock,
|
|
41
45
|
removeBlock,
|
|
42
46
|
resetZoomLevel,
|
|
43
47
|
startDraggingBlocks,
|
|
44
|
-
stopDraggingBlocks
|
|
48
|
+
stopDraggingBlocks,
|
|
49
|
+
editContentOnlySection
|
|
45
50
|
} = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
|
|
46
51
|
return (0, import_compose.useRefEffect)(
|
|
47
52
|
(node) => {
|
|
@@ -196,9 +201,23 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
196
201
|
}
|
|
197
202
|
node.addEventListener("keydown", onKeyDown);
|
|
198
203
|
node.addEventListener("dragstart", onDragStart);
|
|
204
|
+
function onDoubleClick(event) {
|
|
205
|
+
const isSection = isSectionBlock(clientId);
|
|
206
|
+
const isAlreadyEditing = editedContentOnlySection === clientId;
|
|
207
|
+
if (isSection && !isAlreadyEditing) {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
editContentOnlySection(clientId);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (window?.__experimentalContentOnlyPatternInsertion) {
|
|
213
|
+
node.addEventListener("dblclick", onDoubleClick);
|
|
214
|
+
}
|
|
199
215
|
return () => {
|
|
200
216
|
node.removeEventListener("keydown", onKeyDown);
|
|
201
217
|
node.removeEventListener("dragstart", onDragStart);
|
|
218
|
+
if (window?.__experimentalContentOnlyPatternInsertion) {
|
|
219
|
+
node.removeEventListener("dblclick", onDoubleClick);
|
|
220
|
+
}
|
|
202
221
|
};
|
|
203
222
|
},
|
|
204
223
|
[
|
|
@@ -211,7 +230,10 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
211
230
|
resetZoomLevel,
|
|
212
231
|
hasMultiSelection,
|
|
213
232
|
startDraggingBlocks,
|
|
214
|
-
stopDraggingBlocks
|
|
233
|
+
stopDraggingBlocks,
|
|
234
|
+
isSectionBlock,
|
|
235
|
+
editedContentOnlySection,
|
|
236
|
+
editContentOnlySection
|
|
215
237
|
]
|
|
216
238
|
);
|
|
217
239
|
}
|
package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/block-list/use-block-props/use-selected-block-event-handlers.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isTextField } from '@wordpress/dom';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction isColorTransparent( color ) {\n\treturn ! color || color === 'transparent' || color === 'rgba(0, 0, 0, 0)';\n}\n\n/**\n * Adds block behaviour:\n * - Removes the block on BACKSPACE.\n * - Inserts a default block on ENTER.\n * - Disables dragging of block contents.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useEventHandlers( { clientId, isSelected } ) {\n\tconst { getBlockRootClientId, isZoomOut, hasMultiSelection } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\tconst {\n\t\tinsertAfterBlock,\n\t\tremoveBlock,\n\t\tresetZoomLevel,\n\t\tstartDraggingBlocks,\n\t\tstopDraggingBlocks,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Interprets keydown event intent to remove or insert after block if\n\t\t\t * key event occurs on wrapper node. This can occur when the block has\n\t\t\t * no text fields of its own, particularly after initial insertion, to\n\t\t\t * allow for easy deletion and continuous writing flow to add additional\n\t\t\t * content.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keydown event.\n\t\t\t */\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tconst { keyCode, target } = event;\n\n\t\t\t\tif (\n\t\t\t\t\tkeyCode !== ENTER &&\n\t\t\t\t\tkeyCode !== BACKSPACE &&\n\t\t\t\t\tkeyCode !== DELETE\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( target !== node || isTextField( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( keyCode === ENTER && isZoomOut() ) {\n\t\t\t\t\tresetZoomLevel();\n\t\t\t\t} else if ( keyCode === ENTER ) {\n\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Prevents default dragging behavior within a block. To do: we must\n\t\t\t * handle this in the future and clean up the drag target.\n\t\t\t *\n\t\t\t * @param {DragEvent} event Drag event.\n\t\t\t */\n\t\t\tfunction onDragStart( event ) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== event.target ||\n\t\t\t\t\tnode.isContentEditable ||\n\t\t\t\t\tnode.ownerDocument.activeElement !== node ||\n\t\t\t\t\thasMultiSelection()\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = JSON.stringify( {\n\t\t\t\t\ttype: 'block',\n\t\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\t\tsrcRootClientId: getBlockRootClientId( clientId ),\n\t\t\t\t} );\n\t\t\t\tevent.dataTransfer.effectAllowed = 'move'; // remove \"+\" cursor\n\t\t\t\tevent.dataTransfer.clearData();\n\t\t\t\tevent.dataTransfer.setData( 'wp-blocks', data );\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tconst { defaultView } = ownerDocument;\n\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\tselection.removeAllRanges();\n\n\t\t\t\t// Setting the drag chip as the drag image actually works, but\n\t\t\t\t// the behaviour is slightly different in every browser. In\n\t\t\t\t// Safari, it animates, in Firefox it's slightly transparent...\n\t\t\t\t// So we set a fake drag image and have to reposition it\n\t\t\t\t// ourselves.\n\t\t\t\tconst dragElement = ownerDocument.createElement( 'div' );\n\t\t\t\t// Chrome will show a globe icon if the drag element does not\n\t\t\t\t// have dimensions.\n\t\t\t\tdragElement.style.width = '1px';\n\t\t\t\tdragElement.style.height = '1px';\n\t\t\t\tdragElement.style.position = 'fixed';\n\t\t\t\tdragElement.style.visibility = 'hidden';\n\t\t\t\townerDocument.body.appendChild( dragElement );\n\t\t\t\tevent.dataTransfer.setDragImage( dragElement, 0, 0 );\n\n\t\t\t\tconst rect = node.getBoundingClientRect();\n\n\t\t\t\tconst clone = node.cloneNode( true );\n\t\t\t\tclone.style.visibility = 'hidden';\n\t\t\t\t// Maybe remove the clone now that it's relative?\n\t\t\t\tclone.style.display = 'none';\n\n\t\t\t\t// Remove the id and leave it on the clone so that drop target\n\t\t\t\t// calculations are correct.\n\t\t\t\tconst id = node.id;\n\t\t\t\tnode.id = null;\n\n\t\t\t\tlet _scale = 1;\n\n\t\t\t\t{\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { scale } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( scale && scale !== 'none' ) {\n\t\t\t\t\t\t\t_scale = parseFloat( scale );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst inverted = 1 / _scale;\n\n\t\t\t\tnode.after( clone );\n\n\t\t\t\tconst originalNodeProperties = {};\n\t\t\t\tfor ( const property of [\n\t\t\t\t\t'transform',\n\t\t\t\t\t'transformOrigin',\n\t\t\t\t\t'transition',\n\t\t\t\t\t'zIndex',\n\t\t\t\t\t'position',\n\t\t\t\t\t'top',\n\t\t\t\t\t'left',\n\t\t\t\t\t'pointerEvents',\n\t\t\t\t\t'opacity',\n\t\t\t\t\t'backgroundColor',\n\t\t\t\t] ) {\n\t\t\t\t\toriginalNodeProperties[ property ] = node.style[ property ];\n\t\t\t\t}\n\n\t\t\t\t// Get scroll position.\n\t\t\t\tconst originScrollTop = defaultView.scrollY;\n\t\t\t\tconst originScrollLeft = defaultView.scrollX;\n\t\t\t\tconst originClientX = event.clientX;\n\t\t\t\tconst originClientY = event.clientY;\n\n\t\t\t\t// We can't use position fixed because it will behave different\n\t\t\t\t// if the html element is scaled or transformed (position will\n\t\t\t\t// no longer be relative to the viewport). The downside of\n\t\t\t\t// relative is that we have to listen to scroll events. On the\n\t\t\t\t// upside we don't have to clone to keep a space. Absolute\n\t\t\t\t// positioning might be weird because it will be based on the\n\t\t\t\t// positioned parent, but it might be worth a try.\n\t\t\t\tnode.style.position = 'relative';\n\t\t\t\tnode.style.top = `${ 0 }px`;\n\t\t\t\tnode.style.left = `${ 0 }px`;\n\n\t\t\t\tconst originX = event.clientX - rect.left;\n\t\t\t\tconst originY = event.clientY - rect.top;\n\n\t\t\t\t// Scale everything to 200px.\n\t\t\t\tconst dragScale = rect.height > 200 ? 200 / rect.height : 1;\n\n\t\t\t\tnode.style.zIndex = '1000';\n\t\t\t\tnode.style.transformOrigin = `${ originX * inverted }px ${\n\t\t\t\t\toriginY * inverted\n\t\t\t\t}px`;\n\t\t\t\tnode.style.transition = 'transform 0.2s ease-out';\n\t\t\t\tnode.style.transform = `scale(${ dragScale })`;\n\t\t\t\tnode.style.opacity = '0.9';\n\n\t\t\t\t// If the block has no background color, use the parent's\n\t\t\t\t// background color.\n\t\t\t\tif (\n\t\t\t\t\tisColorTransparent(\n\t\t\t\t\t\tdefaultView.getComputedStyle( node ).backgroundColor\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlet bgColor = 'transparent';\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { backgroundColor } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( ! isColorTransparent( backgroundColor ) ) {\n\t\t\t\t\t\t\tbgColor = backgroundColor;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.style.backgroundColor = bgColor;\n\t\t\t\t}\n\n\t\t\t\tlet hasStarted = false;\n\n\t\t\t\tfunction over( e ) {\n\t\t\t\t\tif ( ! hasStarted ) {\n\t\t\t\t\t\thasStarted = true;\n\t\t\t\t\t\tnode.style.pointerEvents = 'none';\n\t\t\t\t\t}\n\t\t\t\t\tconst scrollTop = defaultView.scrollY;\n\t\t\t\t\tconst scrollLeft = defaultView.scrollX;\n\t\t\t\t\tnode.style.top = `${\n\t\t\t\t\t\t( e.clientY -\n\t\t\t\t\t\t\toriginClientY +\n\t\t\t\t\t\t\tscrollTop -\n\t\t\t\t\t\t\toriginScrollTop ) *\n\t\t\t\t\t\tinverted\n\t\t\t\t\t}px`;\n\t\t\t\t\tnode.style.left = `${\n\t\t\t\t\t\t( e.clientX -\n\t\t\t\t\t\t\toriginClientX +\n\t\t\t\t\t\t\tscrollLeft -\n\t\t\t\t\t\t\toriginScrollLeft ) *\n\t\t\t\t\t\tinverted\n\t\t\t\t\t}px`;\n\t\t\t\t}\n\n\t\t\t\tfunction end() {\n\t\t\t\t\townerDocument.removeEventListener( 'dragover', over );\n\t\t\t\t\townerDocument.removeEventListener( 'dragend', end );\n\t\t\t\t\townerDocument.removeEventListener( 'drop', end );\n\t\t\t\t\townerDocument.removeEventListener( 'scroll', over );\n\t\t\t\t\tfor ( const [ property, value ] of Object.entries(\n\t\t\t\t\t\toriginalNodeProperties\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tnode.style[ property ] = value;\n\t\t\t\t\t}\n\t\t\t\t\tclone.remove();\n\t\t\t\t\tnode.id = id;\n\t\t\t\t\tdragElement.remove();\n\t\t\t\t\tstopDraggingBlocks();\n\t\t\t\t\tdocument.body.classList.remove(\n\t\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t\t);\n\t\t\t\t\townerDocument.documentElement.classList.remove(\n\t\t\t\t\t\t'is-dragging'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\townerDocument.addEventListener( 'dragover', over );\n\t\t\t\townerDocument.addEventListener( 'dragend', end );\n\t\t\t\townerDocument.addEventListener( 'drop', end );\n\t\t\t\townerDocument.addEventListener( 'scroll', over );\n\n\t\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\t\t// Important because it hides the block toolbar.\n\t\t\t\tdocument.body.classList.add(\n\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t);\n\t\t\t\townerDocument.documentElement.classList.add( 'is-dragging' );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'dragstart', onDragStart );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'dragstart', onDragStart );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tisSelected,\n\t\t\tgetBlockRootClientId,\n\t\t\tinsertAfterBlock,\n\t\t\tremoveBlock,\n\t\t\tisZoomOut,\n\t\t\tresetZoomLevel,\n\t\t\thasMultiSelection,\n\t\t\tstartDraggingBlocks,\n\t\t\tstopDraggingBlocks,\n\t\t]\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA4B;AAC5B,sBAAyC;AACzC,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,yBAAuB;AAEvB,SAAS,mBAAoB,OAAQ;AACpC,SAAO,CAAE,SAAS,UAAU,iBAAiB,UAAU;AACxD;AAUO,SAAS,iBAAkB,EAAE,UAAU,WAAW,GAAI;AAC5D,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isTextField } from '@wordpress/dom';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction isColorTransparent( color ) {\n\treturn ! color || color === 'transparent' || color === 'rgba(0, 0, 0, 0)';\n}\n\n/**\n * Adds block behaviour:\n * - Removes the block on BACKSPACE.\n * - Inserts a default block on ENTER.\n * - Disables dragging of block contents.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useEventHandlers( { clientId, isSelected } ) {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tisZoomOut,\n\t\thasMultiSelection,\n\t\tisSectionBlock,\n\t\teditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tinsertAfterBlock,\n\t\tremoveBlock,\n\t\tresetZoomLevel,\n\t\tstartDraggingBlocks,\n\t\tstopDraggingBlocks,\n\t\teditContentOnlySection,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Interprets keydown event intent to remove or insert after block if\n\t\t\t * key event occurs on wrapper node. This can occur when the block has\n\t\t\t * no text fields of its own, particularly after initial insertion, to\n\t\t\t * allow for easy deletion and continuous writing flow to add additional\n\t\t\t * content.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keydown event.\n\t\t\t */\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tconst { keyCode, target } = event;\n\n\t\t\t\tif (\n\t\t\t\t\tkeyCode !== ENTER &&\n\t\t\t\t\tkeyCode !== BACKSPACE &&\n\t\t\t\t\tkeyCode !== DELETE\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( target !== node || isTextField( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( keyCode === ENTER && isZoomOut() ) {\n\t\t\t\t\tresetZoomLevel();\n\t\t\t\t} else if ( keyCode === ENTER ) {\n\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Prevents default dragging behavior within a block. To do: we must\n\t\t\t * handle this in the future and clean up the drag target.\n\t\t\t *\n\t\t\t * @param {DragEvent} event Drag event.\n\t\t\t */\n\t\t\tfunction onDragStart( event ) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== event.target ||\n\t\t\t\t\tnode.isContentEditable ||\n\t\t\t\t\tnode.ownerDocument.activeElement !== node ||\n\t\t\t\t\thasMultiSelection()\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = JSON.stringify( {\n\t\t\t\t\ttype: 'block',\n\t\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\t\tsrcRootClientId: getBlockRootClientId( clientId ),\n\t\t\t\t} );\n\t\t\t\tevent.dataTransfer.effectAllowed = 'move'; // remove \"+\" cursor\n\t\t\t\tevent.dataTransfer.clearData();\n\t\t\t\tevent.dataTransfer.setData( 'wp-blocks', data );\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tconst { defaultView } = ownerDocument;\n\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\tselection.removeAllRanges();\n\n\t\t\t\t// Setting the drag chip as the drag image actually works, but\n\t\t\t\t// the behaviour is slightly different in every browser. In\n\t\t\t\t// Safari, it animates, in Firefox it's slightly transparent...\n\t\t\t\t// So we set a fake drag image and have to reposition it\n\t\t\t\t// ourselves.\n\t\t\t\tconst dragElement = ownerDocument.createElement( 'div' );\n\t\t\t\t// Chrome will show a globe icon if the drag element does not\n\t\t\t\t// have dimensions.\n\t\t\t\tdragElement.style.width = '1px';\n\t\t\t\tdragElement.style.height = '1px';\n\t\t\t\tdragElement.style.position = 'fixed';\n\t\t\t\tdragElement.style.visibility = 'hidden';\n\t\t\t\townerDocument.body.appendChild( dragElement );\n\t\t\t\tevent.dataTransfer.setDragImage( dragElement, 0, 0 );\n\n\t\t\t\tconst rect = node.getBoundingClientRect();\n\n\t\t\t\tconst clone = node.cloneNode( true );\n\t\t\t\tclone.style.visibility = 'hidden';\n\t\t\t\t// Maybe remove the clone now that it's relative?\n\t\t\t\tclone.style.display = 'none';\n\n\t\t\t\t// Remove the id and leave it on the clone so that drop target\n\t\t\t\t// calculations are correct.\n\t\t\t\tconst id = node.id;\n\t\t\t\tnode.id = null;\n\n\t\t\t\tlet _scale = 1;\n\n\t\t\t\t{\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { scale } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( scale && scale !== 'none' ) {\n\t\t\t\t\t\t\t_scale = parseFloat( scale );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst inverted = 1 / _scale;\n\n\t\t\t\tnode.after( clone );\n\n\t\t\t\tconst originalNodeProperties = {};\n\t\t\t\tfor ( const property of [\n\t\t\t\t\t'transform',\n\t\t\t\t\t'transformOrigin',\n\t\t\t\t\t'transition',\n\t\t\t\t\t'zIndex',\n\t\t\t\t\t'position',\n\t\t\t\t\t'top',\n\t\t\t\t\t'left',\n\t\t\t\t\t'pointerEvents',\n\t\t\t\t\t'opacity',\n\t\t\t\t\t'backgroundColor',\n\t\t\t\t] ) {\n\t\t\t\t\toriginalNodeProperties[ property ] = node.style[ property ];\n\t\t\t\t}\n\n\t\t\t\t// Get scroll position.\n\t\t\t\tconst originScrollTop = defaultView.scrollY;\n\t\t\t\tconst originScrollLeft = defaultView.scrollX;\n\t\t\t\tconst originClientX = event.clientX;\n\t\t\t\tconst originClientY = event.clientY;\n\n\t\t\t\t// We can't use position fixed because it will behave different\n\t\t\t\t// if the html element is scaled or transformed (position will\n\t\t\t\t// no longer be relative to the viewport). The downside of\n\t\t\t\t// relative is that we have to listen to scroll events. On the\n\t\t\t\t// upside we don't have to clone to keep a space. Absolute\n\t\t\t\t// positioning might be weird because it will be based on the\n\t\t\t\t// positioned parent, but it might be worth a try.\n\t\t\t\tnode.style.position = 'relative';\n\t\t\t\tnode.style.top = `${ 0 }px`;\n\t\t\t\tnode.style.left = `${ 0 }px`;\n\n\t\t\t\tconst originX = event.clientX - rect.left;\n\t\t\t\tconst originY = event.clientY - rect.top;\n\n\t\t\t\t// Scale everything to 200px.\n\t\t\t\tconst dragScale = rect.height > 200 ? 200 / rect.height : 1;\n\n\t\t\t\tnode.style.zIndex = '1000';\n\t\t\t\tnode.style.transformOrigin = `${ originX * inverted }px ${\n\t\t\t\t\toriginY * inverted\n\t\t\t\t}px`;\n\t\t\t\tnode.style.transition = 'transform 0.2s ease-out';\n\t\t\t\tnode.style.transform = `scale(${ dragScale })`;\n\t\t\t\tnode.style.opacity = '0.9';\n\n\t\t\t\t// If the block has no background color, use the parent's\n\t\t\t\t// background color.\n\t\t\t\tif (\n\t\t\t\t\tisColorTransparent(\n\t\t\t\t\t\tdefaultView.getComputedStyle( node ).backgroundColor\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlet bgColor = 'transparent';\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { backgroundColor } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( ! isColorTransparent( backgroundColor ) ) {\n\t\t\t\t\t\t\tbgColor = backgroundColor;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.style.backgroundColor = bgColor;\n\t\t\t\t}\n\n\t\t\t\tlet hasStarted = false;\n\n\t\t\t\tfunction over( e ) {\n\t\t\t\t\tif ( ! hasStarted ) {\n\t\t\t\t\t\thasStarted = true;\n\t\t\t\t\t\tnode.style.pointerEvents = 'none';\n\t\t\t\t\t}\n\t\t\t\t\tconst scrollTop = defaultView.scrollY;\n\t\t\t\t\tconst scrollLeft = defaultView.scrollX;\n\t\t\t\t\tnode.style.top = `${\n\t\t\t\t\t\t( e.clientY -\n\t\t\t\t\t\t\toriginClientY +\n\t\t\t\t\t\t\tscrollTop -\n\t\t\t\t\t\t\toriginScrollTop ) *\n\t\t\t\t\t\tinverted\n\t\t\t\t\t}px`;\n\t\t\t\t\tnode.style.left = `${\n\t\t\t\t\t\t( e.clientX -\n\t\t\t\t\t\t\toriginClientX +\n\t\t\t\t\t\t\tscrollLeft -\n\t\t\t\t\t\t\toriginScrollLeft ) *\n\t\t\t\t\t\tinverted\n\t\t\t\t\t}px`;\n\t\t\t\t}\n\n\t\t\t\tfunction end() {\n\t\t\t\t\townerDocument.removeEventListener( 'dragover', over );\n\t\t\t\t\townerDocument.removeEventListener( 'dragend', end );\n\t\t\t\t\townerDocument.removeEventListener( 'drop', end );\n\t\t\t\t\townerDocument.removeEventListener( 'scroll', over );\n\t\t\t\t\tfor ( const [ property, value ] of Object.entries(\n\t\t\t\t\t\toriginalNodeProperties\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tnode.style[ property ] = value;\n\t\t\t\t\t}\n\t\t\t\t\tclone.remove();\n\t\t\t\t\tnode.id = id;\n\t\t\t\t\tdragElement.remove();\n\t\t\t\t\tstopDraggingBlocks();\n\t\t\t\t\tdocument.body.classList.remove(\n\t\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t\t);\n\t\t\t\t\townerDocument.documentElement.classList.remove(\n\t\t\t\t\t\t'is-dragging'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\townerDocument.addEventListener( 'dragover', over );\n\t\t\t\townerDocument.addEventListener( 'dragend', end );\n\t\t\t\townerDocument.addEventListener( 'drop', end );\n\t\t\t\townerDocument.addEventListener( 'scroll', over );\n\n\t\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\t\t// Important because it hides the block toolbar.\n\t\t\t\tdocument.body.classList.add(\n\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t);\n\t\t\t\townerDocument.documentElement.classList.add( 'is-dragging' );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'dragstart', onDragStart );\n\n\t\t\t/**\n\t\t\t * Handles double-click events on section blocks to edit content only section.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Double-click event.\n\t\t\t */\n\t\t\tfunction onDoubleClick( event ) {\n\t\t\t\tconst isSection = isSectionBlock( clientId );\n\t\t\t\tconst isAlreadyEditing = editedContentOnlySection === clientId;\n\n\t\t\t\tif ( isSection && ! isAlreadyEditing ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\teditContentOnlySection( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Only add double-click listener if experimental flag is enabled\n\t\t\tif ( window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\t\tnode.addEventListener( 'dblclick', onDoubleClick );\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'dragstart', onDragStart );\n\t\t\t\tif ( window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\t\t\tnode.removeEventListener( 'dblclick', onDoubleClick );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tisSelected,\n\t\t\tgetBlockRootClientId,\n\t\t\tinsertAfterBlock,\n\t\t\tremoveBlock,\n\t\t\tisZoomOut,\n\t\t\tresetZoomLevel,\n\t\t\thasMultiSelection,\n\t\t\tstartDraggingBlocks,\n\t\t\tstopDraggingBlocks,\n\t\t\tisSectionBlock,\n\t\t\teditedContentOnlySection,\n\t\t\teditContentOnlySection,\n\t\t]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA4B;AAC5B,sBAAyC;AACzC,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,yBAAuB;AAEvB,SAAS,mBAAoB,OAAQ;AACpC,SAAO,CAAE,SAAS,UAAU,iBAAiB,UAAU;AACxD;AAUO,SAAS,iBAAkB,EAAE,UAAU,WAAW,GAAI;AAC5D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,uBAAW,aAAAA,KAAiB,CAAE;AAC1C,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,yBAAa,aAAAA,KAAiB,CAAE;AAE5C,aAAO;AAAA,IACN,CAAE,SAAU;AACX,UAAK,CAAE,YAAa;AACnB;AAAA,MACD;AAWA,eAAS,UAAW,OAAQ;AAC3B,cAAM,EAAE,SAAS,OAAO,IAAI;AAE5B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ACtC,gBAAM,eAAe;AACrB,iCAAwB,QAAS;AAAA,QAClC;AAAA,MACD;AAGA,UAAK,QAAQ,2CAA4C;AACxD,aAAK,iBAAkB,YAAY,aAAc;AAAA,MAClD;AAEA,aAAO,MAAM;AACZ,aAAK,oBAAqB,WAAW,SAAU;AAC/C,aAAK,oBAAqB,aAAa,WAAY;AACnD,YAAK,QAAQ,2CAA4C;AACxD,eAAK,oBAAqB,YAAY,aAAc;AAAA,QACrD;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -55,7 +55,7 @@ function getTemplateLockValue(lock) {
|
|
|
55
55
|
}
|
|
56
56
|
function BlockLockModal({ clientId, onClose }) {
|
|
57
57
|
const [lock, setLock] = (0, import_element.useState)({ move: false, remove: false });
|
|
58
|
-
const {
|
|
58
|
+
const { isEditLocked, isMoveLocked, isRemoveLocked } = (0, import_use_block_lock.default)(clientId);
|
|
59
59
|
const { allowsEditLocking, templateLock, hasTemplateLock } = (0, import_data.useSelect)(
|
|
60
60
|
(select) => {
|
|
61
61
|
const { getBlockName, getBlockAttributes } = select(import_store.store);
|
|
@@ -76,11 +76,11 @@ function BlockLockModal({ clientId, onClose }) {
|
|
|
76
76
|
const blockInformation = (0, import_use_block_display_information.default)(clientId);
|
|
77
77
|
(0, import_element.useEffect)(() => {
|
|
78
78
|
setLock({
|
|
79
|
-
move:
|
|
80
|
-
remove:
|
|
81
|
-
...allowsEditLocking ? { edit:
|
|
79
|
+
move: isMoveLocked,
|
|
80
|
+
remove: isRemoveLocked,
|
|
81
|
+
...allowsEditLocking ? { edit: isEditLocked } : {}
|
|
82
82
|
});
|
|
83
|
-
}, [
|
|
83
|
+
}, [isEditLocked, isMoveLocked, isRemoveLocked, allowsEditLocking]);
|
|
84
84
|
const isAllChecked = Object.values(lock).every(Boolean);
|
|
85
85
|
const isMixed = Object.values(lock).some(Boolean) && !isAllChecked;
|
|
86
86
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-lock/modal.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAoC;AACpC,wBAQO;AACP,mBAAuD;AACvD,kBAAuC;AACvC,oBAA6B;AAK7B,4BAAyB;AACzB,2CAAuC;AACvC,mBAA0C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { isEditLocked, isMoveLocked, isRemoveLocked } =\n\t\tuseBlockLock( clientId );\n\tconst { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tallowsEditLocking: ALLOWS_EDIT_LOCKING.includes( blockName ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: isMoveLocked,\n\t\t\tremove: isRemoveLocked,\n\t\t\t...( allowsEditLocking ? { edit: isEditLocked } : {} ),\n\t\t} );\n\t}, [ isEditLocked, isMoveLocked, isRemoveLocked, allowsEditLocking ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<fieldset className=\"block-editor-block-lock-modal__options\">\n\t\t\t\t\t<legend>\n\t\t\t\t\t\t{ __( 'Select the features you want to lock' ) }\n\t\t\t\t\t</legend>\n\t\t\t\t\t{ /*\n\t\t\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t\t\t */\n\t\t\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t\t\t<ul\n\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__checklist\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-all\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Lock all' ) }\n\t\t\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t\t\t...( allowsEditLocking\n\t\t\t\t\t\t\t\t\t\t\t? { edit: newValue }\n\t\t\t\t\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ul\n\t\t\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__checklist\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ allowsEditLocking && (\n\t\t\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Lock editing' ) }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.edit\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Lock movement' ) }\n\t\t\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tlock.move ? lockIcon : unlockIcon\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Lock removal' ) }\n\t\t\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tlock.remove ? lockIcon : unlockIcon\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</fieldset>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAoC;AACpC,wBAQO;AACP,mBAAuD;AACvD,kBAAuC;AACvC,oBAA6B;AAK7B,4BAAyB;AACzB,2CAAuC;AACvC,mBAA0C;AA+ErC;AA5EL,IAAM,sBAAsB,CAAE,iBAAkB;AAEhD,SAAS,qBAAsB,MAAO;AAErC,MAAK,KAAK,UAAU,KAAK,MAAO;AAC/B,WAAO;AAAA,EACR;AAGA,MAAK,KAAK,UAAU,CAAE,KAAK,MAAO;AACjC,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAEe,SAAR,eAAiC,EAAE,UAAU,QAAQ,GAAI;AAC/D,QAAM,CAAE,MAAM,OAAQ,QAAI,yBAAU,EAAE,MAAM,OAAO,QAAQ,MAAM,CAAE;AACnE,QAAM,EAAE,cAAc,cAAc,eAAe,QAClD,sBAAAA,SAAc,QAAS;AACxB,QAAM,EAAE,mBAAmB,cAAc,gBAAgB,QAAI;AAAA,IAC5D,CAAE,WAAY;AACb,YAAM,EAAE,cAAc,mBA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|
|
6
6
|
"names": ["useBlockLock", "blockEditorStore", "useBlockDisplayInformation", "lockIcon", "unlockIcon"]
|
|
7
7
|
}
|
|
@@ -25,27 +25,24 @@ __export(use_block_lock_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(use_block_lock_exports);
|
|
26
26
|
var import_data = require("@wordpress/data");
|
|
27
27
|
var import_store = require("../../store");
|
|
28
|
+
var import_lock_unlock = require("../../lock-unlock");
|
|
28
29
|
function useBlockLock(clientId) {
|
|
29
30
|
return (0, import_data.useSelect)(
|
|
30
31
|
(select) => {
|
|
31
32
|
const {
|
|
32
|
-
canEditBlock,
|
|
33
|
-
canMoveBlock,
|
|
34
|
-
canRemoveBlock,
|
|
35
33
|
canLockBlockType,
|
|
36
34
|
getBlockName,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
isEditLockedBlock,
|
|
36
|
+
isMoveLockedBlock,
|
|
37
|
+
isRemoveLockedBlock,
|
|
38
|
+
isLockedBlock
|
|
39
|
+
} = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
42
40
|
return {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
isEditLocked: isEditLockedBlock(clientId),
|
|
42
|
+
isMoveLocked: isMoveLockedBlock(clientId),
|
|
43
|
+
isRemoveLocked: isRemoveLockedBlock(clientId),
|
|
46
44
|
canLock: canLockBlockType(getBlockName(clientId)),
|
|
47
|
-
|
|
48
|
-
isLocked: !canEdit || !canMove || !canRemove
|
|
45
|
+
isLocked: isLockedBlock(clientId)
|
|
49
46
|
};
|
|
50
47
|
},
|
|
51
48
|
[clientId]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-lock/use-block-lock.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Return details about the block lock status.\n *\n * @param {string} clientId The block client Id.\n *\n * @return {Object} Block lock status\n */\nexport default function useBlockLock( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAK1B,mBAA0C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Return details about the block lock status.\n *\n * @param {string} clientId The block client Id.\n *\n * @return {Object} Block lock status\n */\nexport default function useBlockLock( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanLockBlockType,\n\t\t\t\tgetBlockName,\n\t\t\t\tisEditLockedBlock,\n\t\t\t\tisMoveLockedBlock,\n\t\t\t\tisRemoveLockedBlock,\n\t\t\t\tisLockedBlock,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\treturn {\n\t\t\t\tisEditLocked: isEditLockedBlock( clientId ),\n\t\t\t\tisMoveLocked: isMoveLockedBlock( clientId ),\n\t\t\t\tisRemoveLocked: isRemoveLockedBlock( clientId ),\n\t\t\t\tcanLock: canLockBlockType( getBlockName( clientId ) ),\n\t\t\t\tisLocked: isLockedBlock( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAK1B,mBAA0C;AAC1C,yBAAuB;AASR,SAAR,aAA+B,UAAW;AAChD,aAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AAEvC,aAAO;AAAA,QACN,cAAc,kBAAmB,QAAS;AAAA,QAC1C,cAAc,kBAAmB,QAAS;AAAA,QAC1C,gBAAgB,oBAAqB,QAAS;AAAA,QAC9C,SAAS,iBAAkB,aAAc,QAAS,CAAE;AAAA,QACpD,UAAU,cAAe,QAAS;AAAA,MACnC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -68,7 +68,7 @@ var BlockSettingsMenuControlsSlot = ({ fillProps, clientIds = null }) => {
|
|
|
68
68
|
canToggleSelectedBlocksVisibility: getBlocksByClientId(
|
|
69
69
|
ids
|
|
70
70
|
).every(
|
|
71
|
-
(block) => (0, import_blocks.hasBlockSupport)(block.name, "
|
|
71
|
+
(block) => (0, import_blocks.hasBlockSupport)(block.name, "visibility", true)
|
|
72
72
|
)
|
|
73
73
|
};
|
|
74
74
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-settings-menu-controls/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tcreateSlotFill,\n\tMenuGroup,\n\t__experimentalStyleProvider as StyleProvider,\n} from '@wordpress/components';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseConvertToGroupButtonProps,\n\tConvertToGroupButton,\n} from '../convert-to-group-buttons';\nimport { BlockLockMenuItem, useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockModeToggle from '../block-settings-menu/block-mode-toggle';\nimport { ModifyContentOnlySectionMenuItem } from '../content-lock';\nimport { BlockRenameControl, useBlockRename } from '../block-rename';\nimport { BlockVisibilityMenuItem } from '../block-visibility';\nimport { EditSectionMenuItem } from './edit-section-menu-item';\n\nconst { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );\n\nconst BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {\n\tconst {\n\t\tselectedBlocks,\n\t\tselectedClientIds,\n\t\tisContentOnly,\n\t\tcanToggleSelectedBlocksVisibility,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst ids =\n\t\t\t\tclientIds !== null ? clientIds : getSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\tselectedBlocks: getBlockNamesByClientId( ids ),\n\t\t\t\tselectedClientIds: ids,\n\t\t\t\tisContentOnly:\n\t\t\t\t\tgetBlockEditingMode( ids[ 0 ] ) === 'contentOnly',\n\t\t\t\tcanToggleSelectedBlocksVisibility: getBlocksByClientId(\n\t\t\t\t\tids\n\t\t\t\t).every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,oBAAgC;AAChC,kBAA0B;AAK1B,sCAGO;AACP,wBAAgD;AAChD,mBAA0C;AAC1C,+BAA4B;AAC5B,0BAAiD;AACjD,0BAAmD;AACnD,8BAAwC;AACxC,oCAAoC;AAsE/B;AApEL,IAAM,EAAE,MAAM,KAAK,QAAI,kCAAgB,2BAA4B;AAEnE,IAAM,gCAAgC,CAAE,EAAE,WAAW,YAAY,KAAK,MAAO;AAC5E,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,aAAAA,KAAiB;AAC7B,YAAM,MACL,cAAc,OAAO,YAAY,0BAA0B;AAC5D,aAAO;AAAA,QACN,gBAAgB,wBAAyB,GAAI;AAAA,QAC7C,mBAAmB;AAAA,QACnB,eACC,oBAAqB,IAAK,CAAE,CAAE,MAAM;AAAA,QACrC,mCAAmC;AAAA,UAClC;AAAA,QACD,EAAE;AAAA,UAAO,CAAE,cACV,+BAAiB,MAAM,MAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tcreateSlotFill,\n\tMenuGroup,\n\t__experimentalStyleProvider as StyleProvider,\n} from '@wordpress/components';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseConvertToGroupButtonProps,\n\tConvertToGroupButton,\n} from '../convert-to-group-buttons';\nimport { BlockLockMenuItem, useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockModeToggle from '../block-settings-menu/block-mode-toggle';\nimport { ModifyContentOnlySectionMenuItem } from '../content-lock';\nimport { BlockRenameControl, useBlockRename } from '../block-rename';\nimport { BlockVisibilityMenuItem } from '../block-visibility';\nimport { EditSectionMenuItem } from './edit-section-menu-item';\n\nconst { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );\n\nconst BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {\n\tconst {\n\t\tselectedBlocks,\n\t\tselectedClientIds,\n\t\tisContentOnly,\n\t\tcanToggleSelectedBlocksVisibility,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst ids =\n\t\t\t\tclientIds !== null ? clientIds : getSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\tselectedBlocks: getBlockNamesByClientId( ids ),\n\t\t\t\tselectedClientIds: ids,\n\t\t\t\tisContentOnly:\n\t\t\t\t\tgetBlockEditingMode( ids[ 0 ] ) === 'contentOnly',\n\t\t\t\tcanToggleSelectedBlocksVisibility: getBlocksByClientId(\n\t\t\t\t\tids\n\t\t\t\t).every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst { canLock } = useBlockLock( selectedClientIds[ 0 ] );\n\tconst { canRename } = useBlockRename( selectedBlocks[ 0 ] );\n\tconst showLockButton =\n\t\tselectedClientIds.length === 1 && canLock && ! isContentOnly;\n\tconst showRenameButton =\n\t\tselectedClientIds.length === 1 && canRename && ! isContentOnly;\n\tconst showVisibilityButton =\n\t\tcanToggleSelectedBlocksVisibility && ! isContentOnly;\n\n\t// Check if current selection of blocks is Groupable or Ungroupable\n\t// and pass this props down to ConvertToGroupButton.\n\tconst convertToGroupButtonProps =\n\t\tuseConvertToGroupButtonProps( selectedClientIds );\n\tconst { isGroupable, isUngroupable } = convertToGroupButtonProps;\n\tconst showConvertToGroupButton =\n\t\t( isGroupable || isUngroupable ) && ! isContentOnly;\n\n\treturn (\n\t\t<Slot\n\t\t\tfillProps={ {\n\t\t\t\t...fillProps,\n\t\t\t\tselectedBlocks,\n\t\t\t\tselectedClientIds,\n\t\t\t} }\n\t\t>\n\t\t\t{ ( fills ) => {\n\t\t\t\tif (\n\t\t\t\t\t! fills?.length > 0 &&\n\t\t\t\t\t! showConvertToGroupButton &&\n\t\t\t\t\t! showLockButton\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t{ showConvertToGroupButton && (\n\t\t\t\t\t\t\t<ConvertToGroupButton\n\t\t\t\t\t\t\t\t{ ...convertToGroupButtonProps }\n\t\t\t\t\t\t\t\tonClose={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t\t<EditSectionMenuItem\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t\tonClose={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showLockButton && (\n\t\t\t\t\t\t\t<BlockLockMenuItem\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showRenameButton && (\n\t\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showVisibilityButton && (\n\t\t\t\t\t\t\t<BlockVisibilityMenuItem\n\t\t\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t\t<ModifyContentOnlySectionMenuItem\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t\tonClose={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ fillProps?.count === 1 && ! isContentOnly && (\n\t\t\t\t\t\t\t<BlockModeToggle\n\t\t\t\t\t\t\t\tclientId={ fillProps?.firstBlockClientId }\n\t\t\t\t\t\t\t\tonToggle={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t);\n\t\t\t} }\n\t\t</Slot>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md\n *\n * @param {Object} props Fill props.\n * @return {Element} Element.\n */\nfunction BlockSettingsMenuControls( { ...props } ) {\n\treturn (\n\t\t<StyleProvider document={ document }>\n\t\t\t<Fill { ...props } />\n\t\t</StyleProvider>\n\t);\n}\n\nBlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;\n\nexport default BlockSettingsMenuControls;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,oBAAgC;AAChC,kBAA0B;AAK1B,sCAGO;AACP,wBAAgD;AAChD,mBAA0C;AAC1C,+BAA4B;AAC5B,0BAAiD;AACjD,0BAAmD;AACnD,8BAAwC;AACxC,oCAAoC;AAsE/B;AApEL,IAAM,EAAE,MAAM,KAAK,QAAI,kCAAgB,2BAA4B;AAEnE,IAAM,gCAAgC,CAAE,EAAE,WAAW,YAAY,KAAK,MAAO;AAC5E,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,aAAAA,KAAiB;AAC7B,YAAM,MACL,cAAc,OAAO,YAAY,0BAA0B;AAC5D,aAAO;AAAA,QACN,gBAAgB,wBAAyB,GAAI;AAAA,QAC7C,mBAAmB;AAAA,QACnB,eACC,oBAAqB,IAAK,CAAE,CAAE,MAAM;AAAA,QACrC,mCAAmC;AAAA,UAClC;AAAA,QACD,EAAE;AAAA,UAAO,CAAE,cACV,+BAAiB,MAAM,MAAM,cAAc,IAAK;AAAA,QACjD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AAEA,QAAM,EAAE,QAAQ,QAAI,gCAAc,kBAAmB,CAAE,CAAE;AACzD,QA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;AAAA;AAAA,UACvB;AAAA,WAEF;AAAA,MAEF;AAAA;AAAA,EACD;AAEF;AAQA,SAAS,0BAA2B,EAAE,GAAG,MAAM,GAAI;AAClD,SACC,4CAAC,kBAAAC,6BAAA,EAAc,UACd,sDAAC,QAAO,GAAG,OAAQ,GACpB;AAEF;AAEA,0BAA0B,OAAO;AAEjC,IAAO,uCAAQ;",
|
|
6
6
|
"names": ["blockEditorStore", "BlockModeToggle", "StyleProvider"]
|
|
7
7
|
}
|
|
@@ -33,6 +33,7 @@ __export(block_tools_exports, {
|
|
|
33
33
|
default: () => BlockTools
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(block_tools_exports);
|
|
36
|
+
var import_clsx = __toESM(require("clsx"));
|
|
36
37
|
var import_data = require("@wordpress/data");
|
|
37
38
|
var import_dom = require("@wordpress/dom");
|
|
38
39
|
var import_components = require("@wordpress/components");
|
|
@@ -197,7 +198,7 @@ function BlockTools({
|
|
|
197
198
|
const canToggleBlockVisibility = blocks.every(
|
|
198
199
|
(block) => (0, import_blocks.hasBlockSupport)(
|
|
199
200
|
getBlockName(block.clientId),
|
|
200
|
-
"
|
|
201
|
+
"visibility",
|
|
201
202
|
true
|
|
202
203
|
)
|
|
203
204
|
);
|
|
@@ -233,50 +234,60 @@ function BlockTools({
|
|
|
233
234
|
const blockToolbarAfterRef = (0, import_use_popover_scroll.default)(__unstableContentRef);
|
|
234
235
|
return (
|
|
235
236
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
236
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
...props,
|
|
241
|
+
onKeyDown,
|
|
242
|
+
className: (0, import_clsx.default)(props.className, {
|
|
243
|
+
"block-editor-block-tools--is-dragging": isDragging
|
|
244
|
+
}),
|
|
245
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_insertion_point.InsertionPointOpenRef.Provider, { value: (0, import_element.useRef)(false), children: [
|
|
246
|
+
!isTyping && !isZoomOutMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
+
import_insertion_point.default,
|
|
248
|
+
{
|
|
249
|
+
__unstableContentRef
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
showEmptyBlockSideInserter && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
253
|
+
import_empty_block_inserter.default,
|
|
254
|
+
{
|
|
255
|
+
__unstableContentRef,
|
|
256
|
+
clientId
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
showBlockToolbarPopover && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
260
|
+
import_block_toolbar_popover.default,
|
|
261
|
+
{
|
|
262
|
+
__unstableContentRef,
|
|
263
|
+
clientId,
|
|
264
|
+
isTyping
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
!isZoomOutMode && !hasFixedToolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
268
|
+
import_components.Popover.Slot,
|
|
269
|
+
{
|
|
270
|
+
name: "block-toolbar",
|
|
271
|
+
ref: blockToolbarRef
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
children,
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
276
|
+
import_components.Popover.Slot,
|
|
277
|
+
{
|
|
278
|
+
name: "__unstable-block-tools-after",
|
|
279
|
+
ref: blockToolbarAfterRef
|
|
280
|
+
}
|
|
281
|
+
),
|
|
282
|
+
isZoomOutMode && !isDragging && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
283
|
+
import_zoom_out_mode_inserters.default,
|
|
284
|
+
{
|
|
285
|
+
__unstableContentRef
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
] })
|
|
289
|
+
}
|
|
290
|
+
)
|
|
280
291
|
);
|
|
281
292
|
}
|
|
282
293
|
//# sourceMappingURL=index.js.map
|