@wordpress/block-editor 12.8.0 → 12.9.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 +6 -0
- package/README.md +30 -12
- package/build/components/block-controls/slot.js +1 -1
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-controls/slot.native.js +1 -1
- package/build/components/block-controls/slot.native.js.map +1 -1
- package/build/components/block-controls/use-has-block-controls.js +1 -1
- package/build/components/block-controls/use-has-block-controls.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +4 -3
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/index.js +4 -3
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +27 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-nav-mode-exit.js +1 -1
- package/build/components/block-list/use-block-props/use-nav-mode-exit.js.map +1 -1
- package/build/components/block-lock/menu-item.js +3 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/toolbar.js +3 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -5
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +3 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/color-style-selector/index.js +1 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/iframe/index.js +1 -0
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +7 -4
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +10 -8
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inspector-controls/fill.js +1 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +1 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/slot.js +1 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +1 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/link-control/index.js +1 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +48 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +3 -3
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +14 -8
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-images.js +5 -4
- package/build/components/list-view/use-list-view-images.js.map +1 -1
- package/build/components/preview-options/index.js +3 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/rich-text/use-remove-browser-shortcuts.js +1 -1
- package/build/components/rich-text/use-remove-browser-shortcuts.js.map +1 -1
- package/build/components/use-block-commands/index.js +74 -63
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/warning/index.js +1 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/auto-inserting-blocks.js +174 -0
- package/build/hooks/auto-inserting-blocks.js.map +1 -0
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-controls/slot.js +1 -1
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-controls/slot.native.js +1 -1
- package/build-module/components/block-controls/slot.native.js.map +1 -1
- package/build-module/components/block-controls/use-has-block-controls.js +1 -1
- package/build-module/components/block-controls/use-has-block-controls.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +4 -3
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/index.js +4 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +27 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-nav-mode-exit.js +1 -1
- package/build-module/components/block-list/use-block-props/use-nav-mode-exit.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +3 -1
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +3 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -5
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +3 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +1 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -0
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +8 -4
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +11 -8
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +1 -1
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +1 -1
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +1 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +1 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +48 -7
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +3 -3
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +14 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-images.js +5 -4
- package/build-module/components/list-view/use-list-view-images.js.map +1 -1
- package/build-module/components/preview-options/index.js +3 -1
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/rich-text/use-remove-browser-shortcuts.js +1 -1
- package/build-module/components/rich-text/use-remove-browser-shortcuts.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +74 -63
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/warning/index.js +2 -2
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/auto-inserting-blocks.js +167 -0
- package/build-module/hooks/auto-inserting-blocks.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +8 -7
- package/build-style/content.css +8 -7
- package/build-style/style-rtl.css +0 -3
- package/build-style/style.css +0 -3
- package/package.json +32 -32
- package/src/components/block-icon/test/index.js +2 -2
- package/src/components/block-list/block-outline.native.js +5 -2
- package/src/components/block-list/content.scss +2 -3
- package/src/components/block-list/index.js +4 -3
- package/src/components/block-list/use-block-props/index.js +26 -0
- package/src/components/block-list/use-block-props/use-nav-mode-exit.js +1 -1
- package/src/components/block-lock/menu-item.js +2 -0
- package/src/components/block-lock/toolbar.js +3 -1
- package/src/components/block-popover/inbetween.js +4 -3
- package/src/components/block-popover/index.js +3 -2
- package/src/components/block-styles/style.scss +0 -3
- package/src/components/button-block-appender/content.scss +8 -0
- package/src/components/color-style-selector/index.js +1 -1
- package/src/components/iframe/index.js +1 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +7 -2
- package/src/components/inserter/search-results.native.js +13 -9
- package/src/components/link-control/index.js +1 -5
- package/src/components/link-control/test/index.js +1 -0
- package/src/components/list-view/block-select-button.js +67 -15
- package/src/components/list-view/drop-indicator.js +4 -5
- package/src/components/list-view/index.js +19 -13
- package/src/components/list-view/use-list-view-images.js +8 -4
- package/src/components/observe-typing/README.md +2 -2
- package/src/components/preview-options/index.js +2 -0
- package/src/components/provider/index.js +8 -1
- package/src/components/rich-text/use-remove-browser-shortcuts.js +1 -1
- package/src/components/use-block-commands/index.js +92 -88
- package/src/components/warning/index.js +2 -2
- package/src/hooks/auto-inserting-blocks.js +232 -0
- package/src/hooks/index.js +1 -0
- package/src/store/selectors.js +1 -1
- package/build/utils/pre-parse-patterns.js +0 -68
- package/build/utils/pre-parse-patterns.js.map +0 -1
- package/build-module/utils/pre-parse-patterns.js +0 -61
- package/build-module/utils/pre-parse-patterns.js.map +0 -1
- package/src/components/url-popover/test/__snapshots__/index.js.snap +0 -133
- package/src/components/url-popover/test/index.js +0 -75
- package/src/utils/pre-parse-patterns.js +0 -69
|
@@ -30,7 +30,7 @@ export default function BlockControlsSlot({
|
|
|
30
30
|
const Slot = groups[group]?.Slot;
|
|
31
31
|
const fills = useSlotFills(Slot?.__unstableName);
|
|
32
32
|
if (!Slot) {
|
|
33
|
-
typeof
|
|
33
|
+
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning(`Unknown BlockControls group "${group}" provided.`) : void 0;
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
if (!fills?.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","useMemo","privateApis","__experimentalToolbarContext","ToolbarContext","ToolbarGroup","__experimentalUseSlotFills","useSlotFills","warning","groups","unlock","ComponentsContext","BlockControlsSlot","group","props","toolbarState","contextState","fillProps","forwardedContext","Provider","value","Slot","fills","__unstableName","
|
|
1
|
+
{"version":3,"names":["useContext","useMemo","privateApis","__experimentalToolbarContext","ToolbarContext","ToolbarGroup","__experimentalUseSlotFills","useSlotFills","warning","groups","unlock","ComponentsContext","BlockControlsSlot","group","props","toolbarState","contextState","fillProps","forwardedContext","Provider","value","Slot","fills","__unstableName","SCRIPT_DEBUG","length","slot","createElement","bubblesVirtually"],"sources":["@wordpress/block-editor/src/components/block-controls/slot.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useMemo } from '@wordpress/element';\nimport {\n\tprivateApis,\n\t__experimentalToolbarContext as ToolbarContext,\n\tToolbarGroup,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\nimport { unlock } from '../../lock-unlock';\n\nconst { ComponentsContext } = unlock( privateApis );\n\nexport default function BlockControlsSlot( { group = 'default', ...props } ) {\n\tconst toolbarState = useContext( ToolbarContext );\n\tconst contextState = useContext( ComponentsContext );\n\tconst fillProps = useMemo(\n\t\t() => ( {\n\t\t\tforwardedContext: [\n\t\t\t\t[ ToolbarContext.Provider, { value: toolbarState } ],\n\t\t\t\t[ ComponentsContext.Provider, { value: contextState } ],\n\t\t\t],\n\t\t} ),\n\t\t[ toolbarState, contextState ]\n\t);\n\n\tconst Slot = groups[ group ]?.Slot;\n\tconst fills = useSlotFills( Slot?.__unstableName );\n\tif ( ! Slot ) {\n\t\twarning( `Unknown BlockControls group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\n\tif ( ! fills?.length ) {\n\t\treturn null;\n\t}\n\n\tconst slot = <Slot { ...props } bubblesVirtually fillProps={ fillProps } />;\n\n\tif ( group === 'default' ) {\n\t\treturn slot;\n\t}\n\n\treturn <ToolbarGroup>{ slot }</ToolbarGroup>;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;AACxD,SACCC,WAAW,EACXC,4BAA4B,IAAIC,cAAc,EAC9CC,YAAY,EACZC,0BAA0B,IAAIC,YAAY,QACpC,uBAAuB;AAC9B,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAkB,CAAC,GAAGD,MAAM,CAAER,WAAY,CAAC;AAEnD,eAAe,SAASU,iBAAiBA,CAAE;EAAEC,KAAK,GAAG,SAAS;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC5E,MAAMC,YAAY,GAAGf,UAAU,CAAEI,cAAe,CAAC;EACjD,MAAMY,YAAY,GAAGhB,UAAU,CAAEW,iBAAkB,CAAC;EACpD,MAAMM,SAAS,GAAGhB,OAAO,CACxB,OAAQ;IACPiB,gBAAgB,EAAE,CACjB,CAAEd,cAAc,CAACe,QAAQ,EAAE;MAAEC,KAAK,EAAEL;IAAa,CAAC,CAAE,EACpD,CAAEJ,iBAAiB,CAACQ,QAAQ,EAAE;MAAEC,KAAK,EAAEJ;IAAa,CAAC,CAAE;EAEzD,CAAC,CAAE,EACH,CAAED,YAAY,EAAEC,YAAY,CAC7B,CAAC;EAED,MAAMK,IAAI,GAAGZ,MAAM,CAAEI,KAAK,CAAE,EAAEQ,IAAI;EAClC,MAAMC,KAAK,GAAGf,YAAY,CAAEc,IAAI,EAAEE,cAAe,CAAC;EAClD,IAAK,CAAEF,IAAI,EAAG;IACb,OAAAG,YAAA,oBAAAA,YAAA,YAAAhB,OAAO,CAAG,gCAAgCK,KAAO,aAAa,CAAC;IAC/D,OAAO,IAAI;EACZ;EAEA,IAAK,CAAES,KAAK,EAAEG,MAAM,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,MAAMC,IAAI,GAAGC,aAAA,CAACN,IAAI;IAAA,GAAMP,KAAK;IAAGc,gBAAgB;IAACX,SAAS,EAAGA;EAAW,CAAE,CAAC;EAE3E,IAAKJ,KAAK,KAAK,SAAS,EAAG;IAC1B,OAAOa,IAAI;EACZ;EAEA,OAAOC,aAAA,CAACtB,YAAY,QAAGqB,IAAoB,CAAC;AAC7C"}
|
|
@@ -15,7 +15,7 @@ export default function BlockControlsSlot({
|
|
|
15
15
|
}) {
|
|
16
16
|
const Slot = groups[group]?.Slot;
|
|
17
17
|
if (!Slot) {
|
|
18
|
-
typeof
|
|
18
|
+
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning(`Unknown BlockControls group "${group}" provided.`) : void 0;
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
if (group === 'default') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ToolbarGroup","warning","groups","BlockControlsSlot","group","props","Slot","
|
|
1
|
+
{"version":3,"names":["ToolbarGroup","warning","groups","BlockControlsSlot","group","props","Slot","SCRIPT_DEBUG","createElement","fills","length"],"sources":["@wordpress/block-editor/src/components/block-controls/slot.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarGroup } from '@wordpress/components';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\n\nexport default function BlockControlsSlot( { group = 'default', ...props } ) {\n\tconst Slot = groups[ group ]?.Slot;\n\tif ( ! Slot ) {\n\t\twarning( `Unknown BlockControls group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\n\tif ( group === 'default' ) {\n\t\treturn <Slot { ...props } />;\n\t}\n\n\treturn (\n\t\t<Slot { ...props }>\n\t\t\t{ ( fills ) => {\n\t\t\t\tif ( ! fills.length ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\treturn <ToolbarGroup>{ fills }</ToolbarGroup>;\n\t\t\t} }\n\t\t</Slot>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,MAAM,MAAM,UAAU;AAE7B,eAAe,SAASC,iBAAiBA,CAAE;EAAEC,KAAK,GAAG,SAAS;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC5E,MAAMC,IAAI,GAAGJ,MAAM,CAAEE,KAAK,CAAE,EAAEE,IAAI;EAClC,IAAK,CAAEA,IAAI,EAAG;IACb,OAAAC,YAAA,oBAAAA,YAAA,YAAAN,OAAO,CAAG,gCAAgCG,KAAO,aAAa,CAAC;IAC/D,OAAO,IAAI;EACZ;EAEA,IAAKA,KAAK,KAAK,SAAS,EAAG;IAC1B,OAAOI,aAAA,CAACF,IAAI;MAAA,GAAMD;IAAK,CAAI,CAAC;EAC7B;EAEA,OACCG,aAAA,CAACF,IAAI;IAAA,GAAMD;EAAK,GACXI,KAAK,IAAM;IACd,IAAK,CAAEA,KAAK,CAACC,MAAM,EAAG;MACrB,OAAO,IAAI;IACZ;IACA,OAAOF,aAAA,CAACR,YAAY,QAAGS,KAAqB,CAAC;EAC9C,CACK,CAAC;AAET"}
|
|
@@ -26,7 +26,7 @@ export function useHasBlockControls(group = 'default') {
|
|
|
26
26
|
const Slot = groups[group]?.Slot;
|
|
27
27
|
const fills = useSlotFills(Slot?.__unstableName);
|
|
28
28
|
if (!Slot) {
|
|
29
|
-
typeof
|
|
29
|
+
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning(`Unknown BlockControls group "${group}" provided.`) : void 0;
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
return !!fills?.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalUseSlotFills","useSlotFills","warning","groups","useHasAnyBlockControls","hasAnyBlockControls","group","useHasBlockControls","Slot","fills","__unstableName","
|
|
1
|
+
{"version":3,"names":["__experimentalUseSlotFills","useSlotFills","warning","groups","useHasAnyBlockControls","hasAnyBlockControls","group","useHasBlockControls","Slot","fills","__unstableName","SCRIPT_DEBUG","length"],"sources":["@wordpress/block-editor/src/components/block-controls/use-has-block-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseSlotFills as useSlotFills } from '@wordpress/components';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\n\nexport function useHasAnyBlockControls() {\n\tlet hasAnyBlockControls = false;\n\tfor ( const group in groups ) {\n\t\t// It is safe to violate the rules of hooks here as the `groups` object\n\t\t// is static and will not change length between renders. Do not return\n\t\t// early as that will cause the hook to be called a different number of\n\t\t// times between renders.\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tif ( useHasBlockControls( group ) ) {\n\t\t\thasAnyBlockControls = true;\n\t\t}\n\t}\n\treturn hasAnyBlockControls;\n}\n\nexport function useHasBlockControls( group = 'default' ) {\n\tconst Slot = groups[ group ]?.Slot;\n\tconst fills = useSlotFills( Slot?.__unstableName );\n\tif ( ! Slot ) {\n\t\twarning( `Unknown BlockControls group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\treturn !! fills?.length;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,IAAIC,YAAY,QAAQ,uBAAuB;AAClF,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,MAAM,MAAM,UAAU;AAE7B,OAAO,SAASC,sBAAsBA,CAAA,EAAG;EACxC,IAAIC,mBAAmB,GAAG,KAAK;EAC/B,KAAM,MAAMC,KAAK,IAAIH,MAAM,EAAG;IAC7B;IACA;IACA;IACA;IACA;IACA,IAAKI,mBAAmB,CAAED,KAAM,CAAC,EAAG;MACnCD,mBAAmB,GAAG,IAAI;IAC3B;EACD;EACA,OAAOA,mBAAmB;AAC3B;AAEA,OAAO,SAASE,mBAAmBA,CAAED,KAAK,GAAG,SAAS,EAAG;EACxD,MAAME,IAAI,GAAGL,MAAM,CAAEG,KAAK,CAAE,EAAEE,IAAI;EAClC,MAAMC,KAAK,GAAGR,YAAY,CAAEO,IAAI,EAAEE,cAAe,CAAC;EAClD,IAAK,CAAEF,IAAI,EAAG;IACb,OAAAG,YAAA,oBAAAA,YAAA,YAAAT,OAAO,CAAG,gCAAgCI,KAAO,aAAa,CAAC;IAC/D,OAAO,IAAI;EACZ;EACA,OAAO,CAAC,CAAEG,KAAK,EAAEG,MAAM;AACxB"}
|
|
@@ -13,7 +13,7 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
import styles from './block.scss';
|
|
16
|
-
const
|
|
16
|
+
const TEXT_BLOCKS_WITH_OUTLINE = ['core/missing'];
|
|
17
17
|
function BlockOutline({
|
|
18
18
|
blockCategory,
|
|
19
19
|
hasInnerBlocks,
|
|
@@ -21,12 +21,13 @@ function BlockOutline({
|
|
|
21
21
|
isSelected,
|
|
22
22
|
name
|
|
23
23
|
}) {
|
|
24
|
-
const textBlockWithOutline =
|
|
24
|
+
const textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes(name);
|
|
25
|
+
const socialBlockWithOutline = name.includes('core/social-link');
|
|
25
26
|
const hasBlockTextCategory = blockCategory === 'text' && !textBlockWithOutline;
|
|
26
27
|
const hasBlockMediaCategory = blockCategory === 'media' || blockCategory === 'embed' || !blockCategory;
|
|
27
28
|
const shouldShowCompactOutline = hasBlockMediaCategory && !hasInnerBlocks || textBlockWithOutline;
|
|
28
29
|
const styleSolidBorder = [styles.solidBorder, usePreferredColorSchemeStyle(styles.solidBorderColor, styles.solidBorderColorDark), shouldShowCompactOutline && styles.solidBorderCompact, hasBlockTextCategory && styles.solidBorderTextContent];
|
|
29
|
-
const shoudlShowOutline = isSelected && (hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && isRootList || textBlockWithOutline);
|
|
30
|
+
const shoudlShowOutline = isSelected && (hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && hasInnerBlocks || !hasBlockTextCategory && isRootList || socialBlockWithOutline || textBlockWithOutline);
|
|
30
31
|
return shoudlShowOutline && createElement(View, {
|
|
31
32
|
pointerEvents: "box-none",
|
|
32
33
|
style: styleSolidBorder
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","usePreferredColorSchemeStyle","styles","
|
|
1
|
+
{"version":3,"names":["View","usePreferredColorSchemeStyle","styles","TEXT_BLOCKS_WITH_OUTLINE","BlockOutline","blockCategory","hasInnerBlocks","isRootList","isSelected","name","textBlockWithOutline","includes","socialBlockWithOutline","hasBlockTextCategory","hasBlockMediaCategory","shouldShowCompactOutline","styleSolidBorder","solidBorder","solidBorderColor","solidBorderColorDark","solidBorderCompact","solidBorderTextContent","shoudlShowOutline","createElement","pointerEvents","style"],"sources":["@wordpress/block-editor/src/components/block-list/block-outline.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './block.scss';\n\nconst TEXT_BLOCKS_WITH_OUTLINE = [ 'core/missing' ];\n\nfunction BlockOutline( {\n\tblockCategory,\n\thasInnerBlocks,\n\tisRootList,\n\tisSelected,\n\tname,\n} ) {\n\tconst textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes( name );\n\tconst socialBlockWithOutline = name.includes( 'core/social-link' );\n\n\tconst hasBlockTextCategory =\n\t\tblockCategory === 'text' && ! textBlockWithOutline;\n\tconst hasBlockMediaCategory =\n\t\tblockCategory === 'media' ||\n\t\tblockCategory === 'embed' ||\n\t\t! blockCategory;\n\tconst shouldShowCompactOutline =\n\t\t( hasBlockMediaCategory && ! hasInnerBlocks ) || textBlockWithOutline;\n\n\tconst styleSolidBorder = [\n\t\tstyles.solidBorder,\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.solidBorderColor,\n\t\t\tstyles.solidBorderColorDark\n\t\t),\n\t\tshouldShowCompactOutline && styles.solidBorderCompact,\n\t\thasBlockTextCategory && styles.solidBorderTextContent,\n\t];\n\n\tconst shoudlShowOutline =\n\t\tisSelected &&\n\t\t( ( hasBlockTextCategory && hasInnerBlocks ) ||\n\t\t\t( ! hasBlockTextCategory && hasInnerBlocks ) ||\n\t\t\t( ! hasBlockTextCategory && isRootList ) ||\n\t\t\tsocialBlockWithOutline ||\n\t\t\ttextBlockWithOutline );\n\n\treturn (\n\t\tshoudlShowOutline && (\n\t\t\t<View pointerEvents=\"box-none\" style={ styleSolidBorder } />\n\t\t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Z,YAAY"}
|
|
@@ -18,11 +18,11 @@ import BlockListBlock from './block';
|
|
|
18
18
|
import BlockListAppender from '../block-list-appender';
|
|
19
19
|
import { useInBetweenInserter } from './use-in-between-inserter';
|
|
20
20
|
import { store as blockEditorStore } from '../../store';
|
|
21
|
-
import { usePreParsePatterns } from '../../utils/pre-parse-patterns';
|
|
22
21
|
import { LayoutProvider, defaultLayout } from './layout';
|
|
23
22
|
import { useBlockSelectionClearer } from '../block-selection-clearer';
|
|
24
23
|
import { useInnerBlocksProps } from '../inner-blocks';
|
|
25
24
|
import { BlockEditContextProvider, DEFAULT_BLOCK_EDIT_CONTEXT } from '../block-edit/context';
|
|
25
|
+
import { useTypingObserver } from '../observe-typing';
|
|
26
26
|
const elementContext = createContext();
|
|
27
27
|
export const IntersectionObserver = createContext();
|
|
28
28
|
const pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();
|
|
@@ -83,7 +83,7 @@ function Root({
|
|
|
83
83
|
});
|
|
84
84
|
}, []);
|
|
85
85
|
const innerBlocksProps = useInnerBlocksProps({
|
|
86
|
-
ref: useMergeRefs([useBlockSelectionClearer(), useInBetweenInserter(),
|
|
86
|
+
ref: useMergeRefs([useBlockSelectionClearer(), useInBetweenInserter(), useTypingObserver()]),
|
|
87
87
|
className: classnames('is-root-container', className, {
|
|
88
88
|
'is-outline-mode': isOutlineMode,
|
|
89
89
|
'is-focus-mode': isFocusMode && isLargeViewport,
|
|
@@ -96,10 +96,11 @@ function Root({
|
|
|
96
96
|
value: intersectionObserver
|
|
97
97
|
}, createElement("div", {
|
|
98
98
|
...innerBlocksProps
|
|
99
|
+
}), createElement("div", {
|
|
100
|
+
ref: setElement
|
|
99
101
|
})));
|
|
100
102
|
}
|
|
101
103
|
export default function BlockList(settings) {
|
|
102
|
-
usePreParsePatterns();
|
|
103
104
|
return createElement(BlockEditContextProvider, {
|
|
104
105
|
value: DEFAULT_BLOCK_EDIT_CONTEXT
|
|
105
106
|
}, createElement(Root, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","AsyncModeProvider","useSelect","useDispatch","useRegistry","useViewportMatch","useMergeRefs","useDebounce","createContext","useState","useMemo","useCallback","BlockListBlock","BlockListAppender","useInBetweenInserter","store","blockEditorStore","usePreParsePatterns","LayoutProvider","defaultLayout","useBlockSelectionClearer","useInnerBlocksProps","BlockEditContextProvider","DEFAULT_BLOCK_EDIT_CONTEXT","elementContext","IntersectionObserver","pendingBlockVisibilityUpdatesPerRegistry","WeakMap","Root","className","settings","element","setElement","isLargeViewport","isOutlineMode","isFocusMode","editorMode","select","getSettings","__unstableGetEditorMode","outlineMode","focusMode","registry","setBlockVisibility","delayedBlockVisibilityUpdates","updates","get","forEach","id","isIntersecting","trailing","intersectionObserver","Observer","window","entries","set","entry","clientId","target","getAttribute","push","innerBlocksProps","ref","createElement","Provider","value","BlockList","__unstableElementContext","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","layout","order","selectedBlocks","visibleBlocks","getBlockOrder","getSelectedBlockClientIds","__unstableGetVisibleBlocks","map","key","has","includes","length","tagName","BlockListItems","props"],"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAsyncModeProvider,\n\tuseSelect,\n\tuseDispatch,\n\tuseRegistry,\n} from '@wordpress/data';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\tuseDebounce,\n} from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseState,\n\tuseMemo,\n\tuseCallback,\n} from '@wordpress/element';\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 { usePreParsePatterns } from '../../utils/pre-parse-patterns';\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';\n\nconst elementContext = createContext();\n\nexport const IntersectionObserver = createContext();\nconst pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();\n\nfunction Root( { className, ...settings } ) {\n\tconst [ element, setElement ] = useState();\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, editorMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetEditorMode } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\teditorMode: __unstableGetEditorMode(),\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\t{\n\t\t\ttrailing: true,\n\t\t}\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\tsetElement,\n\t\t\t] ),\n\t\t\tclassName: classnames( 'is-root-container', className, {\n\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t'is-navigate-mode': editorMode === 'navigation',\n\t\t\t} ),\n\t\t},\n\t\tsettings\n\t);\n\treturn (\n\t\t<elementContext.Provider value={ element }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</IntersectionObserver.Provider>\n\t\t</elementContext.Provider>\n\t);\n}\n\nexport default function BlockList( settings ) {\n\tusePreParsePatterns();\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\nBlockList.__unstableElementContext = elementContext;\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\tlayout = defaultLayout,\n} ) {\n\tconst { order, selectedBlocks, visibleBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetVisibleBlocks,\n\t\t\t} = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t\tvisibleBlocks: __unstableGetVisibleBlocks(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\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<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</AsyncModeProvider>\n\t\t\t) ) }\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\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\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,SAAS,EACTC,WAAW,EACXC,WAAW,QACL,iBAAiB;AACxB,SACCC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,QACL,oBAAoB;AAC3B,SACCC,aAAa,EACbC,QAAQ,EACRC,OAAO,EACPC,WAAW,QACL,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAOC,cAAc,MAAM,SAAS;AACpC,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ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QAAS,CAAC,IAC/B,CAAEkB,cAAc,CAACQ,QAAQ,CAAE1B,QAAS;EACpC,GAEDM,aAAA,CAACnD,cAAc;IACd0D,YAAY,EAAGA,YAAc;IAC7Bb,QAAQ,EAAGA;EAAU,CACrB,CACiB,CAClB,CAAC,EACDiB,KAAK,CAACU,MAAM,GAAG,CAAC,IAAIf,WAAW,EACjCN,aAAA,CAAClD,iBAAiB;IACjBwE,OAAO,EAAGb,6BAA+B;IACzCF,YAAY,EAAGA,YAAc;IAC7BC,cAAc,EAAGA;EAAgB,CACjC,CACc,CAAC;AAEnB;AAEA,OAAO,SAASe,cAAcA,CAAEC,KAAK,EAAG;EACvC;EACA;EACA,OACCxB,aAAA,CAAC9D,iBAAiB;IAACgE,KAAK,EAAG;EAAO,GACjCF,aAAA,CAACK,KAAK;IAAA,GAAMmB;EAAK,CAAI,CACH,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["classnames","AsyncModeProvider","useSelect","useDispatch","useRegistry","useViewportMatch","useMergeRefs","useDebounce","createContext","useState","useMemo","useCallback","BlockListBlock","BlockListAppender","useInBetweenInserter","store","blockEditorStore","LayoutProvider","defaultLayout","useBlockSelectionClearer","useInnerBlocksProps","BlockEditContextProvider","DEFAULT_BLOCK_EDIT_CONTEXT","useTypingObserver","elementContext","IntersectionObserver","pendingBlockVisibilityUpdatesPerRegistry","WeakMap","Root","className","settings","element","setElement","isLargeViewport","isOutlineMode","isFocusMode","editorMode","select","getSettings","__unstableGetEditorMode","outlineMode","focusMode","registry","setBlockVisibility","delayedBlockVisibilityUpdates","updates","get","forEach","id","isIntersecting","trailing","intersectionObserver","Observer","window","entries","set","entry","clientId","target","getAttribute","push","innerBlocksProps","ref","createElement","Provider","value","BlockList","__unstableElementContext","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","layout","order","selectedBlocks","visibleBlocks","getBlockOrder","getSelectedBlockClientIds","__unstableGetVisibleBlocks","map","key","has","includes","length","tagName","BlockListItems","props"],"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAsyncModeProvider,\n\tuseSelect,\n\tuseDispatch,\n\tuseRegistry,\n} from '@wordpress/data';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\tuseDebounce,\n} from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseState,\n\tuseMemo,\n\tuseCallback,\n} from '@wordpress/element';\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';\n\nconst elementContext = createContext();\n\nexport const IntersectionObserver = createContext();\nconst pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();\n\nfunction Root( { className, ...settings } ) {\n\tconst [ element, setElement ] = useState();\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, editorMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetEditorMode } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\teditorMode: __unstableGetEditorMode(),\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\t{\n\t\t\ttrailing: true,\n\t\t}\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: classnames( 'is-root-container', className, {\n\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t'is-navigate-mode': editorMode === 'navigation',\n\t\t\t} ),\n\t\t},\n\t\tsettings\n\t);\n\treturn (\n\t\t<elementContext.Provider value={ element }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t{ /* Ensure element and layout styles are always at the end of the document */ }\n\t\t\t\t<div ref={ setElement } />\n\t\t\t</IntersectionObserver.Provider>\n\t\t</elementContext.Provider>\n\t);\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\nBlockList.__unstableElementContext = elementContext;\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\tlayout = defaultLayout,\n} ) {\n\tconst { order, selectedBlocks, visibleBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetVisibleBlocks,\n\t\t\t} = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t\tvisibleBlocks: __unstableGetVisibleBlocks(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\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<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</AsyncModeProvider>\n\t\t\t) ) }\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\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\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,SAAS,EACTC,WAAW,EACXC,WAAW,QACL,iBAAiB;AACxB,SACCC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,QACL,oBAAoB;AAC3B,SACCC,aAAa,EACbC,QAAQ,EACRC,OAAO,EACPC,WAAW,QACL,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAOC,cAAc,MAAM,SAAS;AACpC,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,cAAc,EAAEC,aAAa,QAAQ,UAAU;AACxD,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SACCC,wBAAwB,EACxBC,0BAA0B,QACpB,uBAAuB;AAC9B,SAASC,iBAAiB,QAAQ,mBAAmB;AAErD,MAAMC,cAAc,GAAGhB,aAAa,CAAC,CAAC;AAEtC,OAAO,MAAMiB,oBAAoB,GAAGjB,aAAa,CAAC,CAAC;AACnD,MAAMkB,wCAAwC,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE9D,SAASC,IAAIA,CAAE;EAAEC,SAAS;EAAE,GAAGC;AAAS,CAAC,EAAG;EAC3C,MAAM,CAAEC,OAAO,EAAEC,UAAU,CAAE,GAAGvB,QAAQ,CAAC,CAAC;EAC1C,MAAMwB,eAAe,GAAG5B,gBAAgB,CAAE,QAAS,CAAC;EACpD,MAAM;IAAE6B,aAAa;IAAEC,WAAW;IAAEC;EAAW,CAAC,GAAGlC,SAAS,CACzDm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
|
|
49
49
|
* also pass any other props through this hook, and they will be merged and
|
|
50
50
|
* returned.
|
|
51
51
|
*
|
|
52
|
+
* Use of this hook on the outermost element of a block is required if using API >= v2.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```js
|
|
56
|
+
* import { useBlockProps } from '@wordpress/block-editor';
|
|
57
|
+
*
|
|
58
|
+
* export default function Edit() {
|
|
59
|
+
*
|
|
60
|
+
* const blockProps = useBlockProps(
|
|
61
|
+
* className: 'my-custom-class',
|
|
62
|
+
* style: {
|
|
63
|
+
* color: '#222222',
|
|
64
|
+
* backgroundColor: '#eeeeee'
|
|
65
|
+
* }
|
|
66
|
+
* )
|
|
67
|
+
*
|
|
68
|
+
* return (
|
|
69
|
+
* <div { ...blockProps }>
|
|
70
|
+
*
|
|
71
|
+
* </div>
|
|
72
|
+
* )
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
*
|
|
52
78
|
* @param {Object} props Optional. Props to pass to the element. Must contain
|
|
53
79
|
* the ref if one is defined.
|
|
54
80
|
* @param {Object} options Options for internal use only.
|
|
@@ -126,7 +152,7 @@ export function useBlockProps(props = {}, {
|
|
|
126
152
|
const blockEditContext = useBlockEditContext();
|
|
127
153
|
// Ensures it warns only inside the `edit` implementation for the block.
|
|
128
154
|
if (blockApiVersion < 2 && clientId === blockEditContext.clientId) {
|
|
129
|
-
typeof
|
|
155
|
+
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning(`Block type "${name}" must support API version 2 or higher to work correctly with "useBlockProps" method.`) : void 0;
|
|
130
156
|
}
|
|
131
157
|
return {
|
|
132
158
|
tabIndex: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useContext","__","sprintf","__unstableGetBlockProps","getBlockProps","getBlockType","store","blocksStore","useMergeRefs","useDisabled","useSelect","warning","useMovingAnimation","BlockListBlockContext","useFocusFirstElement","useIsHovered","useBlockEditContext","useBlockClassNames","useBlockDefaultClassName","useBlockCustomClassName","useBlockMovingModeClassNames","useFocusHandler","useEventHandlers","useNavModeExit","useBlockRefProvider","useIntersectionObserver","blockEditorStore","useBlockOverlayActive","unlock","BLOCK_ANIMATION_THRESHOLD","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","index","mode","name","blockApiVersion","blockTitle","isPartOfSelection","adjustScrolling","enableAnimation","isSubtreeDisabled","select","getBlockAttributes","getBlockIndex","getBlockMode","getBlockName","isTyping","getGlobalBlockCount","isBlockSelected","isBlockMultiSelected","isAncestorMultiSelected","isFirstMultiSelectedBlock","isBlockSubtreeDisabled","getActiveBlockVariation","isSelected","isPartOfMultiSelection","blockName","blockType","attributes","match","apiVersion","title","hasOverlay","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","isDisabled","blockEditContext","process","env","NODE_ENV","tabIndex","id","role","inert","undefined","style","save"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__unstableGetBlockProps as getBlockProps,\n\tgetBlockType,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { BlockListBlockContext } from '../block-list-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport { useBlockEditContext } from '../../block-edit/context';\nimport { useBlockClassNames } from './use-block-class-names';\nimport { useBlockDefaultClassName } from './use-block-default-class-name';\nimport { useBlockCustomClassName } from './use-block-custom-class-name';\nimport { useBlockMovingModeClassNames } from './use-block-moving-mode-class-names';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { store as blockEditorStore } from '../../../store';\nimport useBlockOverlayActive from '../../block-content-overlay';\nimport { unlock } from '../../../lock-unlock';\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\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t} = useContext( BlockListBlockContext );\n\tconst {\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisPartOfSelection,\n\t\tadjustScrolling,\n\t\tenableAnimation,\n\t\tisSubtreeDisabled,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisTyping,\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tisAncestorMultiSelected,\n\t\t\t\tisFirstMultiSelectedBlock,\n\t\t\t\tisBlockSubtreeDisabled,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { getActiveBlockVariation } = select( blocksStore );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst isPartOfMultiSelection =\n\t\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\t\tisAncestorMultiSelected( clientId );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\n\t\t\treturn {\n\t\t\t\tindex: getBlockIndex( clientId ),\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tname: blockName,\n\t\t\t\tblockApiVersion: blockType?.apiVersion || 1,\n\t\t\t\tblockTitle: match?.title || blockType?.title,\n\t\t\t\tisPartOfSelection: isSelected || isPartOfMultiSelection,\n\t\t\t\tadjustScrolling:\n\t\t\t\t\tisSelected || isFirstMultiSelectedBlock( clientId ),\n\t\t\t\tenableAnimation:\n\t\t\t\t\t! isTyping() &&\n\t\t\t\t\tgetGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,\n\t\t\t\tisSubtreeDisabled: isBlockSubtreeDisabled( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst hasOverlay = useBlockOverlayActive( clientId );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( clientId ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( clientId ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered(),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( {\n\t\t\tisSelected: isPartOfSelection,\n\t\t\tadjustScrolling,\n\t\t\tenableAnimation,\n\t\t\ttriggerAnimationOnChange: index,\n\t\t} ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\treturn {\n\t\ttabIndex: 0,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: classnames(\n\t\t\t// The wp-block className is important for editor styles.\n\t\t\tclassnames( 'block-editor-block-list__block', {\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t} ),\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tuseBlockClassNames( clientId ),\n\t\t\tuseBlockDefaultClassName( clientId ),\n\t\t\tuseBlockCustomClassName( clientId ),\n\t\t\tuseBlockMovingModeClassNames( clientId )\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,uBAAuB,IAAIC,aAAa,EACxCC,YAAY,EACZC,KAAK,IAAIC,WAAW,QACd,mBAAmB;AAC1B,SAASC,YAAY,EAAEC,WAAW,QAAQ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Y,EAAEZ,UAAU;IACxB,YAAY,EAAEnC,QAAQ;IACtB,WAAW,EAAEM,IAAI;IACjB,YAAY,EAAEE,UAAU;IACxBwC,KAAK,EAAEpC,iBAAiB,GAAG,MAAM,GAAGqC,SAAS;IAC7ChD,SAAS,EAAEnC,UAAU;IACpB;IACAA,UAAU,CAAE,gCAAgC,EAAE;MAC7C,UAAU,EAAE,CAAEqC,SAAS;MACvB,mBAAmB,EAAE+B;IACtB,CAAE,CAAC,EACHjC,SAAS,EACTH,KAAK,CAACG,SAAS,EACfC,YAAY,CAACD,SAAS,EACtBjB,kBAAkB,CAAEgB,QAAS,CAAC,EAC9Bf,wBAAwB,CAAEe,QAAS,CAAC,EACpCd,uBAAuB,CAAEc,QAAS,CAAC,EACnCb,4BAA4B,CAAEa,QAAS,CACxC,CAAC;IACDkD,KAAK,EAAE;MAAE,GAAGhD,YAAY,CAACgD,KAAK;MAAE,GAAGpD,KAAK,CAACoD;IAAM;EAChD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACArD,aAAa,CAACsD,IAAI,GAAGhF,aAAa"}
|
|
1
|
+
{"version":3,"names":["classnames","useContext","__","sprintf","__unstableGetBlockProps","getBlockProps","getBlockType","store","blocksStore","useMergeRefs","useDisabled","useSelect","warning","useMovingAnimation","BlockListBlockContext","useFocusFirstElement","useIsHovered","useBlockEditContext","useBlockClassNames","useBlockDefaultClassName","useBlockCustomClassName","useBlockMovingModeClassNames","useFocusHandler","useEventHandlers","useNavModeExit","useBlockRefProvider","useIntersectionObserver","blockEditorStore","useBlockOverlayActive","unlock","BLOCK_ANIMATION_THRESHOLD","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","index","mode","name","blockApiVersion","blockTitle","isPartOfSelection","adjustScrolling","enableAnimation","isSubtreeDisabled","select","getBlockAttributes","getBlockIndex","getBlockMode","getBlockName","isTyping","getGlobalBlockCount","isBlockSelected","isBlockMultiSelected","isAncestorMultiSelected","isFirstMultiSelectedBlock","isBlockSubtreeDisabled","getActiveBlockVariation","isSelected","isPartOfMultiSelection","blockName","blockType","attributes","match","apiVersion","title","hasOverlay","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","isDisabled","blockEditContext","SCRIPT_DEBUG","tabIndex","id","role","inert","undefined","style","save"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__unstableGetBlockProps as getBlockProps,\n\tgetBlockType,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { BlockListBlockContext } from '../block-list-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport { useBlockEditContext } from '../../block-edit/context';\nimport { useBlockClassNames } from './use-block-class-names';\nimport { useBlockDefaultClassName } from './use-block-default-class-name';\nimport { useBlockCustomClassName } from './use-block-custom-class-name';\nimport { useBlockMovingModeClassNames } from './use-block-moving-mode-class-names';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { store as blockEditorStore } from '../../../store';\nimport useBlockOverlayActive from '../../block-content-overlay';\nimport { unlock } from '../../../lock-unlock';\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\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps(\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t} = useContext( BlockListBlockContext );\n\tconst {\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisPartOfSelection,\n\t\tadjustScrolling,\n\t\tenableAnimation,\n\t\tisSubtreeDisabled,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisTyping,\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tisAncestorMultiSelected,\n\t\t\t\tisFirstMultiSelectedBlock,\n\t\t\t\tisBlockSubtreeDisabled,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { getActiveBlockVariation } = select( blocksStore );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst isPartOfMultiSelection =\n\t\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\t\tisAncestorMultiSelected( clientId );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\n\t\t\treturn {\n\t\t\t\tindex: getBlockIndex( clientId ),\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tname: blockName,\n\t\t\t\tblockApiVersion: blockType?.apiVersion || 1,\n\t\t\t\tblockTitle: match?.title || blockType?.title,\n\t\t\t\tisPartOfSelection: isSelected || isPartOfMultiSelection,\n\t\t\t\tadjustScrolling:\n\t\t\t\t\tisSelected || isFirstMultiSelectedBlock( clientId ),\n\t\t\t\tenableAnimation:\n\t\t\t\t\t! isTyping() &&\n\t\t\t\t\tgetGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,\n\t\t\t\tisSubtreeDisabled: isBlockSubtreeDisabled( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst hasOverlay = useBlockOverlayActive( clientId );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( clientId ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( clientId ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered(),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( {\n\t\t\tisSelected: isPartOfSelection,\n\t\t\tadjustScrolling,\n\t\t\tenableAnimation,\n\t\t\ttriggerAnimationOnChange: index,\n\t\t} ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\treturn {\n\t\ttabIndex: 0,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: classnames(\n\t\t\t// The wp-block className is important for editor styles.\n\t\t\tclassnames( 'block-editor-block-list__block', {\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t} ),\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tuseBlockClassNames( clientId ),\n\t\t\tuseBlockDefaultClassName( clientId ),\n\t\t\tuseBlockCustomClassName( clientId ),\n\t\t\tuseBlockMovingModeClassNames( clientId )\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,uBAAuB,IAAIC,aAAa,EACxCC,YAAY,EACZC,KAAK,IAAIC,WAAW,QACd,mBAAmB;AAC1B,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;AAC9D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,SAASC,q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YAAY,EAAEE,UAAU;IACxBsC,KAAK,EAAElC,iBAAiB,GAAG,MAAM,GAAGmC,SAAS;IAC7C9C,SAAS,EAAEnC,UAAU;IACpB;IACAA,UAAU,CAAE,gCAAgC,EAAE;MAC7C,UAAU,EAAE,CAAEqC,SAAS;MACvB,mBAAmB,EAAE+B;IACtB,CAAE,CAAC,EACHjC,SAAS,EACTH,KAAK,CAACG,SAAS,EACfC,YAAY,CAACD,SAAS,EACtBjB,kBAAkB,CAAEgB,QAAS,CAAC,EAC9Bf,wBAAwB,CAAEe,QAAS,CAAC,EACpCd,uBAAuB,CAAEc,QAAS,CAAC,EACnCb,4BAA4B,CAAEa,QAAS,CACxC,CAAC;IACDgD,KAAK,EAAE;MAAE,GAAG9C,YAAY,CAAC8C,KAAK;MAAE,GAAGlD,KAAK,CAACkD;IAAM;EAChD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACAnD,aAAa,CAACoD,IAAI,GAAG9E,aAAa"}
|
|
@@ -41,7 +41,7 @@ export function useNavModeExit(clientId) {
|
|
|
41
41
|
}
|
|
42
42
|
node.addEventListener('mousedown', onMouseDown);
|
|
43
43
|
return () => {
|
|
44
|
-
node.
|
|
44
|
+
node.removeEventListener('mousedown', onMouseDown);
|
|
45
45
|
};
|
|
46
46
|
}, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]);
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","useNavModeExit","clientId","isNavigationMode","isBlockSelected","setNavigationMode","selectBlock","node","onMouseDown","event","defaultPrevented","preventDefault","addEventListener"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-nav-mode-exit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Allows navigation mode to be exited by clicking in the selected block.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useNavModeExit( clientId ) {\n\tconst { isNavigationMode, isBlockSelected } = useSelect( blockEditorStore );\n\tconst { setNavigationMode, selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// Don't select a block if it's already handled by a child\n\t\t\t\t// block.\n\t\t\t\tif ( isNavigationMode() && ! event.defaultPrevented ) {\n\t\t\t\t\t// Prevent focus from moving to the block.\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t// When clicking on a selected block, exit navigation mode.\n\t\t\t\t\tif ( isBlockSelected( clientId ) ) {\n\t\t\t\t\t\tsetNavigationMode( false );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","useNavModeExit","clientId","isNavigationMode","isBlockSelected","setNavigationMode","selectBlock","node","onMouseDown","event","defaultPrevented","preventDefault","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-nav-mode-exit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Allows navigation mode to be exited by clicking in the selected block.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useNavModeExit( clientId ) {\n\tconst { isNavigationMode, isBlockSelected } = useSelect( blockEditorStore );\n\tconst { setNavigationMode, selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// Don't select a block if it's already handled by a child\n\t\t\t\t// block.\n\t\t\t\tif ( isNavigationMode() && ! event.defaultPrevented ) {\n\t\t\t\t\t// Prevent focus from moving to the block.\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t// When clicking on a selected block, exit navigation mode.\n\t\t\t\t\tif ( isBlockSelected( clientId ) ) {\n\t\t\t\t\t\tsetNavigationMode( false );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[ clientId, isNavigationMode, isBlockSelected, setNavigationMode ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,gBAAgB;;AAE1D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAEC,QAAQ,EAAG;EAC1C,MAAM;IAAEC,gBAAgB;IAAEC;EAAgB,CAAC,GAAGR,SAAS,CAAEI,gBAAiB,CAAC;EAC3E,MAAM;IAAEK,iBAAiB;IAAEC;EAAY,CAAC,GAAGT,WAAW,CAAEG,gBAAiB,CAAC;EAC1E,OAAOF,YAAY,CAChBS,IAAI,IAAM;IACX,SAASC,WAAWA,CAAEC,KAAK,EAAG;MAC7B;MACA;MACA,IAAKN,gBAAgB,CAAC,CAAC,IAAI,CAAEM,KAAK,CAACC,gBAAgB,EAAG;QACrD;QACAD,KAAK,CAACE,cAAc,CAAC,CAAC;;QAEtB;QACA,IAAKP,eAAe,CAAEF,QAAS,CAAC,EAAG;UAClCG,iBAAiB,CAAE,KAAM,CAAC;QAC3B,CAAC,MAAM;UACNC,WAAW,CAAEJ,QAAS,CAAC;QACxB;MACD;IACD;IAEAK,IAAI,CAACK,gBAAgB,CAAE,WAAW,EAAEJ,WAAY,CAAC;IAEjD,OAAO,MAAM;MACZD,IAAI,CAACM,mBAAmB,CAAE,WAAW,EAAEL,WAAY,CAAC;IACrD,CAAC;EACF,CAAC,EACD,CAAEN,QAAQ,EAAEC,gBAAgB,EAAEC,eAAe,EAAEC,iBAAiB,CACjE,CAAC;AACF"}
|
|
@@ -26,7 +26,9 @@ export default function BlockLockMenuItem({
|
|
|
26
26
|
const label = isLocked ? __('Unlock') : __('Lock');
|
|
27
27
|
return createElement(Fragment, null, createElement(MenuItem, {
|
|
28
28
|
icon: isLocked ? unlock : lockOutline,
|
|
29
|
-
onClick: toggleModal
|
|
29
|
+
onClick: toggleModal,
|
|
30
|
+
"aria-expanded": isModalOpen,
|
|
31
|
+
"aria-haspopup": "dialog"
|
|
30
32
|
}, label), isModalOpen && createElement(BlockLockModal, {
|
|
31
33
|
clientId: clientId,
|
|
32
34
|
onClose: toggleModal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useReducer","MenuItem","lockOutline","unlock","useBlockLock","BlockLockModal","BlockLockMenuItem","clientId","canLock","isLocked","isModalOpen","toggleModal","isActive","label","createElement","Fragment","icon","onClick","onClose"],"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { lockOutline, unlock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport BlockLockModal from './modal';\n\nexport default function BlockLockMenuItem( { clientId } ) {\n\tconst { canLock, isLocked } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLock ) {\n\t\treturn null;\n\t}\n\n\tconst label = isLocked ? __( 'Unlock' ) : __( 'Lock' );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ isLocked ? unlock : lockOutline }\n\t\t\t\tonClick={ toggleModal }\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,WAAW,EAAEC,MAAM,QAAQ,kBAAkB;;AAEtD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,cAAc,MAAM,SAAS;AAEpC,eAAe,SAASC,iBAAiBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACzD,MAAM;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGL,YAAY,CAAEG,QAAS,CAAC;EAEtD,MAAM,CAAEG,WAAW,EAAEC,WAAW,CAAE,GAAGX,UAAU,CAC5CY,QAAQ,IAAM,CAAEA,QAAQ,EAC1B,KACD,CAAC;EAED,IAAK,CAAEJ,OAAO,EAAG;IAChB,OAAO,IAAI;EACZ;EAEA,MAAMK,KAAK,GAAGJ,QAAQ,GAAGV,EAAE,CAAE,QAAS,CAAC,GAAGA,EAAE,CAAE,MAAO,CAAC;EAEtD,OACCe,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACb,QAAQ;IACRe,IAAI,EAAGP,QAAQ,GAAGN,MAAM,GAAGD,WAAa;IACxCe,OAAO,EAAGN;
|
|
1
|
+
{"version":3,"names":["__","useReducer","MenuItem","lockOutline","unlock","useBlockLock","BlockLockModal","BlockLockMenuItem","clientId","canLock","isLocked","isModalOpen","toggleModal","isActive","label","createElement","Fragment","icon","onClick","onClose"],"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { lockOutline, unlock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport BlockLockModal from './modal';\n\nexport default function BlockLockMenuItem( { clientId } ) {\n\tconst { canLock, isLocked } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLock ) {\n\t\treturn null;\n\t}\n\n\tconst label = isLocked ? __( 'Unlock' ) : __( 'Lock' );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ isLocked ? unlock : lockOutline }\n\t\t\t\tonClick={ toggleModal }\n\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,WAAW,EAAEC,MAAM,QAAQ,kBAAkB;;AAEtD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,cAAc,MAAM,SAAS;AAEpC,eAAe,SAASC,iBAAiBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACzD,MAAM;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGL,YAAY,CAAEG,QAAS,CAAC;EAEtD,MAAM,CAAEG,WAAW,EAAEC,WAAW,CAAE,GAAGX,UAAU,CAC5CY,QAAQ,IAAM,CAAEA,QAAQ,EAC1B,KACD,CAAC;EAED,IAAK,CAAEJ,OAAO,EAAG;IAChB,OAAO,IAAI;EACZ;EAEA,MAAMK,KAAK,GAAGJ,QAAQ,GAAGV,EAAE,CAAE,QAAS,CAAC,GAAGA,EAAE,CAAE,MAAO,CAAC;EAEtD,OACCe,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACb,QAAQ;IACRe,IAAI,EAAGP,QAAQ,GAAGN,MAAM,GAAGD,WAAa;IACxCe,OAAO,EAAGN,WAAa;IACvB,iBAAgBD,WAAa;IAC7B,iBAAc;EAAQ,GAEpBG,KACO,CAAC,EACTH,WAAW,IACZI,aAAA,CAACT,cAAc;IAACE,QAAQ,EAAGA,QAAU;IAACW,OAAO,EAAGP;EAAa,CAAE,CAE/D,CAAC;AAEL"}
|
|
@@ -49,10 +49,12 @@ export default function BlockLockToolbar({
|
|
|
49
49
|
return createElement(Fragment, null, createElement(ToolbarGroup, {
|
|
50
50
|
className: "block-editor-block-lock-toolbar"
|
|
51
51
|
}, createElement(ToolbarButton, {
|
|
52
|
+
ref: lockButtonRef,
|
|
52
53
|
icon: lock,
|
|
53
54
|
label: __('Unlock'),
|
|
54
55
|
onClick: toggleModal,
|
|
55
|
-
|
|
56
|
+
"aria-expanded": isModalOpen,
|
|
57
|
+
"aria-haspopup": "dialog"
|
|
56
58
|
})), isModalOpen && createElement(BlockLockModal, {
|
|
57
59
|
clientId: clientId,
|
|
58
60
|
onClose: toggleModal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","ToolbarButton","ToolbarGroup","focus","useReducer","useRef","useEffect","lock","BlockLockModal","useBlockLock","BlockLockToolbar","clientId","wrapperRef","canEdit","canMove","canRemove","canLock","isModalOpen","toggleModal","isActive","lockButtonRef","isFirstRender","shouldHideBlockLockUI","current","focusable","find","sequential","element","tagName","createElement","Fragment","className","icon","label","onClick","
|
|
1
|
+
{"version":3,"names":["__","ToolbarButton","ToolbarGroup","focus","useReducer","useRef","useEffect","lock","BlockLockModal","useBlockLock","BlockLockToolbar","clientId","wrapperRef","canEdit","canMove","canRemove","canLock","isModalOpen","toggleModal","isActive","lockButtonRef","isFirstRender","shouldHideBlockLockUI","current","focusable","find","sequential","element","tagName","createElement","Fragment","className","ref","icon","label","onClick","onClose"],"sources":["@wordpress/block-editor/src/components/block-lock/toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { focus } from '@wordpress/dom';\nimport { useReducer, useRef, useEffect } from '@wordpress/element';\nimport { lock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockLockModal from './modal';\nimport useBlockLock from './use-block-lock';\n\nexport default function BlockLockToolbar( { clientId, wrapperRef } ) {\n\tconst { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tconst lockButtonRef = useRef( null );\n\tconst isFirstRender = useRef( true );\n\n\tconst shouldHideBlockLockUI =\n\t\t! canLock || ( canEdit && canMove && canRemove );\n\n\t// Restore focus manually on the first focusable element in the toolbar\n\t// when the block lock modal is closed and the block is not locked anymore.\n\t// See https://github.com/WordPress/gutenberg/issues/51447\n\tuseEffect( () => {\n\t\tif ( isFirstRender.current ) {\n\t\t\tisFirstRender.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isModalOpen && shouldHideBlockLockUI ) {\n\t\t\tfocus.focusable\n\t\t\t\t.find( wrapperRef.current, {\n\t\t\t\t\tsequential: false,\n\t\t\t\t} )\n\t\t\t\t.find(\n\t\t\t\t\t( element ) =>\n\t\t\t\t\t\telement.tagName === 'BUTTON' &&\n\t\t\t\t\t\telement !== lockButtonRef.current\n\t\t\t\t)\n\t\t\t\t?.focus();\n\t\t}\n\t\t// wrapperRef is a reference object and should be stable\n\t}, [ isModalOpen, shouldHideBlockLockUI, wrapperRef ] );\n\n\tif ( shouldHideBlockLockUI ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarGroup className=\"block-editor-block-lock-toolbar\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ lockButtonRef }\n\t\t\t\t\ticon={ lock }\n\t\t\t\t\tlabel={ __( 'Unlock' ) }\n\t\t\t\t\tonClick={ toggleModal }\n\t\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,UAAU,EAAEC,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAClE,SAASC,IAAI,QAAQ,kBAAkB;;AAEvC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,SAAS;AACpC,OAAOC,YAAY,MAAM,kBAAkB;AAE3C,eAAe,SAASC,gBAAgBA,CAAE;EAAEC,QAAQ;EAAEC;AAAW,CAAC,EAAG;EACpE,MAAM;IAAEC,OAAO;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAQ,CAAC,GAAGP,YAAY,CAAEE,QAAS,CAAC;EAEzE,MAAM,CAAEM,WAAW,EAAEC,WAAW,CAAE,GAAGd,UAAU,CAC5Ce,QAAQ,IAAM,CAAEA,QAAQ,EAC1B,KACD,CAAC;EAED,MAAMC,aAAa,GAAGf,MAAM,CAAE,IAAK,CAAC;EACpC,MAAMgB,aAAa,GAAGhB,MAAM,CAAE,IAAK,CAAC;EAEpC,MAAMiB,qBAAqB,GAC1B,CAAEN,OAAO,IAAMH,OAAO,IAAIC,OAAO,IAAIC,SAAW;;EAEjD;EACA;EACA;EACAT,SAAS,CAAE,MAAM;IAChB,IAAKe,aAAa,CAACE,OAAO,EAAG;MAC5BF,aAAa,CAACE,OAAO,GAAG,KAAK;MAC7B;IACD;IAEA,IAAK,CAAEN,WAAW,IAAIK,qBAAqB,EAAG;MAC7CnB,KAAK,CAACqB,SAAS,CACbC,IAAI,CAAEb,UAAU,CAACW,OAAO,EAAE;QAC1BG,UAAU,EAAE;MACb,CAAE,CAAC,CACFD,IAAI,CACFE,OAAO,IACRA,OAAO,CAACC,OAAO,KAAK,QAAQ,IAC5BD,OAAO,KAAKP,aAAa,CAACG,OAC5B,CAAC,EACCpB,KAAK,CAAC,CAAC;IACX;IACA;EACD,CAAC,EAAE,CAAEc,WAAW,EAAEK,qBAAqB,EAAEV,UAAU,CAAG,CAAC;EAEvD,IAAKU,qBAAqB,EAAG;IAC5B,OAAO,IAAI;EACZ;EAEA,OACCO,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAC3B,YAAY;IAAC6B,SAAS,EAAC;EAAiC,GACxDF,aAAA,CAAC5B,aAAa;IACb+B,GAAG,EAAGZ,aAAe;IACrBa,IAAI,EAAG1B,IAAM;IACb2B,KAAK,EAAGlC,EAAE,CAAE,QAAS,CAAG;IACxBmC,OAAO,EAAGjB,WAAa;IACvB,iBAAgBD,WAAa;IAC7B,iBAAc;EAAQ,CACtB,CACY,CAAC,EACbA,WAAW,IACZY,aAAA,CAACrB,cAAc;IAACG,QAAQ,EAAGA,QAAU;IAACyB,OAAO,EAAGlB;EAAa,CAAE,CAE/D,CAAC;AAEL"}
|
|
@@ -60,11 +60,9 @@ function BlockPopoverInbetween({
|
|
|
60
60
|
popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
|
-
const
|
|
64
|
-
ownerDocument
|
|
65
|
-
} = previousElement || nextElement;
|
|
63
|
+
const contextElement = previousElement || nextElement;
|
|
66
64
|
return {
|
|
67
|
-
|
|
65
|
+
contextElement,
|
|
68
66
|
getBoundingClientRect() {
|
|
69
67
|
const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
|
|
70
68
|
const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
|
|
@@ -161,7 +159,8 @@ function BlockPopoverInbetween({
|
|
|
161
159
|
// Render in the old slot if needed for backward compatibility,
|
|
162
160
|
// otherwise render in place (not in the default popover slot).
|
|
163
161
|
,
|
|
164
|
-
__unstableSlotName: __unstablePopoverSlot
|
|
162
|
+
__unstableSlotName: __unstablePopoverSlot,
|
|
163
|
+
inline: !__unstablePopoverSlot
|
|
165
164
|
// Forces a remount of the popover when its position changes
|
|
166
165
|
// This makes sure the popover doesn't animate from its previous position.
|
|
167
166
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useSelect","useMemo","createContext","useReducer","useLayoutEffect","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","_rootClientId","previousElement","nextElement","isVertical","popoverAnchor","undefined","ownerDocument","getBoundingClientRect","previousRect","nextRect","left","top","width","height","bottom","right","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","createElement","ref","animate","anchor","focusOnMount","__unstableSlotName","key","className","resize","flip","placement","variant"],"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth = previousRect ? previousRect.width : nextRect.width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iB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CACG,CAAC;EAEX;AACD;;AAEA,eAAeH,qBAAqB"}
|
|
1
|
+
{"version":3,"names":["classnames","useSelect","useMemo","createContext","useReducer","useLayoutEffect","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","_rootClientId","previousElement","nextElement","isVertical","popoverAnchor","undefined","contextElement","getBoundingClientRect","previousRect","nextRect","left","top","width","height","bottom","right","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","ownerDocument","defaultView","addEventListener","removeEventListener","createElement","ref","animate","anchor","focusOnMount","__unstableSlotName","inline","key","className","resize","flip","placement","variant"],"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst contextElement = previousElement || nextElement;\n\n\t\treturn {\n\t\t\tcontextElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth = previousRect ? previousRect.width : nextRect.width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,OAAO,EACPC,aAAa,EACbC,UAAU,EACVC,eAAe,QACT,oBAAoB;AAC3B,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,yBAAyB,IAAIC,eAAe,QAAQ,8CAA8C;AAC3G,OAAOC,gBAAgB,MAAM,sBAAsB;AAEnD,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAE7D,OAAO,MAAMC,qBAAqB,GAAGb,aAAa,CAAC,CAAC;AAEpD,SAASc,qBAAqBA,CAAE;EAC/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AAa,CAACC,WAAW,EAAEE,mBAAmB,CAC7D,QAAQ,EACRpC,qBACD,CAAC;IACF,CAAC;EACF,CAAC,EAAE,CAAEU,eAAe,CAAG,CAAC;;EAExB;EACA;EACA;EACA,IAAO,CAAEA,eAAe,IAAI,CAAEC,WAAW,IAAM,CAAEP,SAAS,EAAG;IAC5D,OAAO,IAAI;EACZ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OACCiC,aAAA,CAACxD,OAAO;IACPyD,GAAG,EAAGX,gBAAkB;IACxBY,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAG3B,aAAe;IACxB4B,YAAY,EAAG;IACf;IACA;IAAA;IACAC,kBAAkB,EAAG9C,qBAAuB;IAC5C+C,MAAM,EAAG,CAAE/C;IACX;IACA;IAAA;IACAgD,GAAG,EAAGlD,YAAY,GAAG,IAAI,GAAGS,YAAc;IAAA,GACrCL,KAAK;IACV+C,SAAS,EAAGtE,UAAU,CACrB,4BAA4B,EAC5B,uCAAuC,EACvCuB,KAAK,CAAC+C,SACP,CAAG;IACHC,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdC,SAAS,EAAC,SAAS;IACnBC,OAAO,EAAC;EAAU,GAElBZ,aAAA;IAAKQ,SAAS,EAAC;EAAiD,GAC7DlD,QACE,CACG,CAAC;EAEX;AACD;;AAEA,eAAeH,qBAAqB"}
|
|
@@ -94,7 +94,7 @@ function BlockPopover({
|
|
|
94
94
|
const height = bottom - top;
|
|
95
95
|
return new window.DOMRect(left, top, width, height);
|
|
96
96
|
},
|
|
97
|
-
|
|
97
|
+
contextElement: selectedElement
|
|
98
98
|
};
|
|
99
99
|
}, [bottomClientId, lastSelectedElement, selectedElement, popoverDimensionsRecomputeCounter]);
|
|
100
100
|
if (!selectedElement || bottomClientId && !lastSelectedElement) {
|
|
@@ -108,7 +108,8 @@ function BlockPopover({
|
|
|
108
108
|
// Render in the old slot if needed for backward compatibility,
|
|
109
109
|
// otherwise render in place (not in the default popover slot).
|
|
110
110
|
,
|
|
111
|
-
__unstableSlotName: __unstablePopoverSlot
|
|
111
|
+
__unstableSlotName: __unstablePopoverSlot,
|
|
112
|
+
inline: !__unstablePopoverSlot,
|
|
112
113
|
placement: "top-start",
|
|
113
114
|
resize: false,
|
|
114
115
|
flip: false,
|